Changeset 26557


Ignore:
Timestamp:
2012-12-05T15:13:28+13:00 (11 years ago)
Author:
sjm84
Message:

Fixing string fragments being missing after some being moved to interface_default2.properties

File:
1 edited

Legend:

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

    r26471 r26557  
    3838import org.greenstone.util.GlobalProperties;
    3939import org.w3c.dom.Node;
    40 import org.w3c.dom.NodeList;
    4140
    4241/**
     
    143142        return oidParts[0];
    144143    }
    145 
    146144
    147145    public static String replace(String orig, String match, String replacement)
     
    234232    }
    235233
     234    public static String getInterfaceText(String interfaceName, String dictionaryName, String lang, String key, String args_str)
     235    {
     236        key = key.replaceAll("__INTERFACE_NAME__", interfaceName);
     237
     238        String[] args = null;
     239        if (args_str != null && !args_str.equals(""))
     240        {
     241            args = StringUtils.split(args_str, ";");
     242        }
     243        Dictionary dict = new Dictionary(dictionaryName, lang);
     244        String result = dict.get(key, args);
     245        if (result == null)
     246        { // not found
     247            //if not found, search a separate subdirectory named by the interface name
     248            String sep_interface_dir = interfaceName + File.separatorChar + lang + File.separatorChar + "interface";
     249            dict = new Dictionary(sep_interface_dir, lang);
     250            result = dict.get(key, args);
     251            if (result != null)
     252            {
     253                result = result.replaceAll("__INTERFACE_NAME__", interfaceName);
     254                return result;
     255            }
     256        }
     257
     258        if (result == null && !interfaceName.equals("default"))
     259        { // not found, try the default interface
     260            dict = new Dictionary("interface_default", lang);
     261            result = dict.get(key, args);
     262        }
     263
     264        if (result == null)
     265        { // not found
     266            return "_" + key + "_";
     267        }
     268        result = result.replaceAll("__INTERFACE_NAME__", interfaceName);
     269        return result;
     270    }
     271
    236272    public static String getInterfaceTextWithDOM(String interface_name, String lang, String key, Node arg_node)
    237273    {
     
    685721        outputStr.append("}\n");
    686722
    687         Dictionary dict = new Dictionary("interface_" + interface_name, lang);
    688         Enumeration keys = dict.getKeys();
    689         if (keys == null)
    690         { // try default interface
    691             //logger.debug("****** Interface name: " + interface_name + " does not have any keys. Trying interface_default.");
    692             dict = new Dictionary("interface_default", lang);
    693             keys = dict.getKeys();
    694         }
    695 
    696         // Get all properties in the language-specific dictionary with the given key prefix
    697         // Create Javascript strings of the form:
    698         // prependToPrefix.key= "value";\n
    699         while (keys.hasMoreElements())
    700         {
    701             String key = (String) keys.nextElement();
    702             if (key.startsWith(prefix))
    703             {
    704                 String value = getInterfaceText(interface_name, lang, key);
    705 
    706                 outputStr.append(prependToPrefix);
    707                 outputStr.append(".");
    708                 outputStr.append(key);
    709                 outputStr.append("=\"");
    710                 outputStr.append(value);
    711                 outputStr.append("\";\n");
     723        int foundCount = 0;
     724
     725        for (String dictName : new String[] { "interface_" + interface_name, "interface_default", "interface_default2" })
     726        {
     727            Dictionary dict = new Dictionary(dictName, lang);
     728            Enumeration keys = dict.getKeys();
     729            if (keys == null)
     730            {
     731                continue;
     732            }
     733
     734            // Get all properties in the language-specific dictionary with the given key prefix
     735            // Create Javascript strings of the form:
     736            // prependToPrefix.key= "value";\n
     737            while (keys.hasMoreElements())
     738            {
     739                String key = (String) keys.nextElement();
     740                if (key.startsWith(prefix))
     741                {
     742                    String value = getInterfaceText(interface_name, dictName, lang, key, null);
     743
     744                    outputStr.append(prependToPrefix);
     745                    outputStr.append(".");
     746                    outputStr.append(key);
     747                    outputStr.append("=\"");
     748                    outputStr.append(value);
     749                    outputStr.append("\";\n");
     750                }
     751            }
     752
     753            if (foundCount > 0)
     754            {
     755                break;
    712756            }
    713757        }
Note: See TracChangeset for help on using the changeset viewer.