Changeset 26557
- Timestamp:
- 2012-12-05T15:13:28+13:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java
r26471 r26557 38 38 import org.greenstone.util.GlobalProperties; 39 39 import org.w3c.dom.Node; 40 import org.w3c.dom.NodeList;41 40 42 41 /** … … 143 142 return oidParts[0]; 144 143 } 145 146 144 147 145 public static String replace(String orig, String match, String replacement) … … 234 232 } 235 233 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 236 272 public static String getInterfaceTextWithDOM(String interface_name, String lang, String key, Node arg_node) 237 273 { … … 685 721 outputStr.append("}\n"); 686 722 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; 712 756 } 713 757 }
Note:
See TracChangeset
for help on using the changeset viewer.