Ignore:
Timestamp:
2012-04-12T15:47:24+12:00 (12 years ago)
Author:
ak19
Message:

Java method getInterfaceStringsAsJavascript outputs more of the javascript so that the XSLT has to output less of it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java

    r25353 r25378  
    513513    }
    514514
    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(); }
    516526    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");
    517533   
    518534    Dictionary dict = new Dictionary("interface_" + interface_name, lang);
    519535    Enumeration keys = dict.getKeys(); 
    520536    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.");
    522538        dict = new Dictionary("interface_default", lang);
    523539        keys = dict.getKeys();
    524540    }
    525541   
    526     // get all properties in the language-specific dictionary with the given key prefix
    527     // Create a string of prependToPrefix.key= "value";\n
    528 
     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
    529545    while(keys.hasMoreElements()) {     
    530546        String key = (String)keys.nextElement();
     
    545561    }
    546562
    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
    548565    public static void main(String args[]) {
    549566    System.out.println("\n@@@@@\n" + XSLTUtil.getInterfaceStringsAsJavascript("default", "en", "dse", "gs.text") + "@@@@@\n");
Note: See TracChangeset for help on using the changeset viewer.