- Timestamp:
- 2012-04-12T15:47:24+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java
r25353 r25378 513 513 } 514 514 515 public static String getInterfaceStringsAsJavascript(String interface_name, String lang, String prefix, String prependToPrefix) { 515 public static String getInterfaceStringsAsJavascript(String interface_name, String lang, String prefix) { 516 String prependToPrefix = "gs.text"; 517 return XSLTUtil.getInterfaceStringsAsJavascript(interface_name, lang, prefix, prependToPrefix); 518 } 519 520 // generates javascript: 2 arrays are declared and populated with strings that declare variables and assign their values 521 // to be strings loaded from the interface_name.properties file for the language. 522 public static String getInterfaceStringsAsJavascript(String interface_name, String lang, String prefix, String prependToPrefix) { 523 // 1. Generating Javascript of the form: 524 // if(!gs.text) { gs.text = new Array(); } 525 // if(!gs.text.dse) { gs.text.dse = new Array(); } 516 526 StringBuffer outputStr = new StringBuffer(); 527 outputStr.append("if(!gs.text) { "); 528 outputStr.append(prependToPrefix + " = new Array(); "); 529 outputStr.append("}\n"); 530 outputStr.append("if(!gs.text." + prefix + ") { "); 531 outputStr.append(prependToPrefix + "." + prefix + " = new Array(); "); 532 outputStr.append("}\n"); 517 533 518 534 Dictionary dict = new Dictionary("interface_" + interface_name, lang); 519 535 Enumeration keys = dict.getKeys(); 520 536 if(keys == null) { // try default interface 521 logger.error("****** Interface name: " + interface_name + " does not have any keys. Trying interface_default.");537 //logger.debug("****** Interface name: " + interface_name + " does not have any keys. Trying interface_default."); 522 538 dict = new Dictionary("interface_default", lang); 523 539 keys = dict.getKeys(); 524 540 } 525 541 526 // get all properties in the language-specific dictionary with the given key prefix527 // Create a string of prependToPrefix.key= "value";\n528 542 // Get all properties in the language-specific dictionary with the given key prefix 543 // Create Javascript strings of the form: 544 // prependToPrefix.key= "value";\n 529 545 while(keys.hasMoreElements()) { 530 546 String key = (String)keys.nextElement(); … … 545 561 } 546 562 547 563 // Test from cmdline with: 564 // java -classpath /research/ak19/gs3-svn/web/WEB-INF/lib/gsdl3.jar:/research/ak19/gs3-svn/web/WEB-INF/lib/log4j-1.2.8.jar:/research/ak19/gs3-svn/web/WEB-INF/classes/ org.greenstone.gsdl3.util.XSLTUtil 548 565 public static void main(String args[]) { 549 566 System.out.println("\n@@@@@\n" + XSLTUtil.getInterfaceStringsAsJavascript("default", "en", "dse", "gs.text") + "@@@@@\n");
Note:
See TracChangeset
for help on using the changeset viewer.