Changeset 7022
- Timestamp:
- 2004-03-12T10:07:13+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Configuration.java
r6655 r7022 76 76 77 77 static final private String GENERAL_EMAIL_SETTING = "general.email"; 78 /** the lang attribute of the other element */ 79 static final private String LANGUAGE = "lang"; 78 80 /** The name of a Name Element. */ 79 81 static final private String NAME = "Name"; … … 332 334 Element argument_element = null; 333 335 try { 334 336 // Retrieve the other information subtree. 335 337 Element document_element = general_config.getDocumentElement(); 336 338 Element other_element = (Element) MSMUtils.getNodeFromNamed(document_element, OTHER); … … 355 357 } 356 358 return argument_element; 359 } 360 361 /** Gets the language for the other arguments subtree 362 @return empty string if no language specified */ 363 public String getArgumentsLanguage() { 364 Element document_element = general_config.getDocumentElement(); 365 Element other_element = (Element) MSMUtils.getNodeFromNamed(document_element, OTHER); 366 String lang = other_element.getAttribute(LANGUAGE); 367 if (lang == null) { 368 lang = "en"; 369 } 370 return lang; 357 371 } 358 372 … … 683 697 Element document_element = general_config.getDocumentElement(); 684 698 Element other_element = (Element) MSMUtils.getNodeFromNamed(document_element, OTHER); 685 699 // Retrieve the name of the information 686 700 Element arguments_name_element = (Element)MSMUtils.getNodeFromNamed(arguments_element, NAME); 687 701 String filename = MSMUtils.getValue(arguments_element); 688 702 // Find any argument information subtree starting with the same name 689 703 Element obsolete_arguments_element = getArguments(filename); 690 704 // Create a copy of the arguments_element within our tree (import). 691 705 Element our_arguments_element = (Element) general_config.importNode(arguments_element, true); 692 706 // Now we insert this new node into the tree. If a previous node exists we replace it instead. 693 707 if(obsolete_arguments_element == null) { 694 708 other_element.appendChild(our_arguments_element); … … 710 724 } 711 725 726 /** Sets the language for the other arguments subtree */ 727 public void setArgumentsLanguage(String lang) { 728 Element document_element = general_config.getDocumentElement(); 729 Element other_element = (Element) MSMUtils.getNodeFromNamed(document_element, OTHER); 730 other_element.setAttribute(LANGUAGE, lang); 731 } 732 733 712 734 /** Set the collection configuration. */ 713 735 public void setCollectionConfiguration(Document collection_config) { -
trunk/gli/src/org/greenstone/gatherer/collection/BuildOptions.java
r6384 r7022 43 43 /** When constructing a BuildOptions object we first try to retrieve the valid arguments from config.xml. If that fails we then try to parse the arguments noticed when calling import.pl -xml and buildcol.pl -xml. If that also fails, we load the default arguments from the xml template library. */ 44 44 public BuildOptions(Element build_values_element, Element import_values_element) { 45 // Try to retrieve the arguments for import and build. 46 build_arguments_element = Gatherer.config.getArguments("buildcol.pl"); 47 import_arguments_element = Gatherer.config.getArguments("import.pl"); 45 // first check the saved arguments language 46 String interface_lang = Gatherer.config.getLanguage(); 47 String args_lang = Gatherer.config.getArgumentsLanguage(); 48 if (interface_lang.equals(args_lang)) { 49 // Try to retrieve the arguments for import and build. 50 build_arguments_element = Gatherer.config.getArguments("buildcol.pl"); 51 import_arguments_element = Gatherer.config.getArguments("import.pl"); 52 } 48 53 // If that fails try to reconstruct the arguments 49 54 if(build_arguments_element == null || import_arguments_element == null) { 50 build_arguments_element = loadArguments("buildcol.pl"); 51 import_arguments_element = loadArguments("import.pl"); 55 boolean used_defaults = false; 56 build_arguments_element = loadArguments("buildcol.pl", interface_lang); 57 import_arguments_element = loadArguments("import.pl", interface_lang); 52 58 // And if that too fails, load the default argument templates 53 59 if(build_arguments_element == null || import_arguments_element == null) { … … 58 64 import_arguments_element = import_document.getDocumentElement(); 59 65 import_document = null; 66 used_defaults = true; 60 67 ///atherer.println("Loaded default BO arguments from templates."); 61 68 } … … 64 71 } 65 72 // By now we should definately have the arguments. However the reason we are here is because they are not stored in the config.xml file, to make sure they are stored now. 73 if (used_defaults) { 74 Gatherer.config.setArgumentsLanguage("en"); 75 } else { 76 Gatherer.config.setArgumentsLanguage(interface_lang); 77 } 66 78 Gatherer.config.setArguments(build_arguments_element); 67 79 Gatherer.config.setArguments(import_arguments_element); … … 363 375 } 364 376 365 private Element loadArguments(String filename ) {377 private Element loadArguments(String filename, String lang) { 366 378 Element arguments_element = null; 367 379 // Run the required program. … … 369 381 String args[]; 370 382 if(Utility.isWindows()) { 371 args = new String[ 4];383 args = new String[6]; 372 384 args[0] = Gatherer.config.perl_path; 373 385 args[1] = "-S"; 374 386 args[2] = Gatherer.config.getScriptPath() + filename; 375 387 args[3] = "-xml"; 388 args[4] = "-language"; 389 args[5] = lang; 376 390 } 377 391 else { 378 args = new String[ 2];392 args = new String[4]; 379 393 args[0] = Gatherer.config.getScriptPath() + filename; 380 394 args[1] = "-xml"; 395 args[2] = "-language"; 396 args[3] = lang; 381 397 } 382 398 // Create the process. … … 384 400 Process process = runtime.exec(args); 385 401 //InputStream input_stream = process.getErrorStream(); 386 InputSource source = new InputSource(new InputStreamReader(process.getErrorStream() ));402 InputSource source = new InputSource(new InputStreamReader(process.getErrorStream(), "UTF-8")); 387 403 DOMParser parser = new DOMParser(); 388 404 parser.parse(source);
Note:
See TracChangeset
for help on using the changeset viewer.