Changeset 4702


Ignore:
Timestamp:
2003-06-18T11:54:54+12:00 (21 years ago)
Author:
kjdon
Message:

added method for retrieving strings from resource bundles, including ones with args

File:
1 edited

Legend:

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

    r4271 r4702  
    11package org.greenstone.gsdl3.util;
    22
    3 /** a class to contain static methods that are used by the xslt
     3/** a class to contain various static methods that are used by the xslt
    44 * stylesheets
    55 */
     
    2222    }
    2323
    24     public static int getInt(String orig) {
    25     return 20;
    26     }
    27    
    28     public static String getString(String orig) {
    29     return orig;
    30     }
    31 
    3224    public static String getNumberedItem(String list, int number) {
    3325    String [] items = list.split(",", -1); 
     
    4739    return new_s;
    4840    }
     41
     42
     43    public static String getInterfaceText(String interface_name, String lang, String key) {
     44    return getInterfaceText(interface_name, lang, key, null);
     45    }
     46    public static String getInterfaceText(String interface_name, String lang, String key, String args_str) {
     47    String [] args = null;
     48    if (args_str!=null && !args_str.equals("")) {
     49        args = args_str.split(";");
     50    }
     51    Dictionary dict = new Dictionary("interface_"+interface_name, lang);
     52        String result = dict.get(key, args);
     53
     54    if (result == null && !interface_name.equals("default")) { // not found, try the default interface
     55        dict = new Dictionary("interface_default", lang);
     56        result = dict.get(key, args);
     57    }
     58       
     59        if (result == null) { // not found
     60            return "_"+key+"_";
     61        }
     62        return result;
     63    }
    4964}
     65
Note: See TracChangeset for help on using the changeset viewer.