- Timestamp:
- 2022-01-13T14:56:08+13:00 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java
r35996 r35998 822 822 } 823 823 824 /** 825 * Generates a Javascript object graph to store language strings. Leaf nodes are the key, and their value the string. 826 * Further preceding nodes denote the prefix of the string within the language strings property file. 827 * Accessing a language string from the object graph can be done as such: 'const myString = gs.text.{prefix}.{key};' 828 * @param interfaceName The name of the interface to retrieve language strings for. 829 * @param lang The language to retrieve. 830 * @param prefix The prefix to to retrieve strings under. E.g. a value of 'atea.macroniser' will only retrieve strings prefixed with that value. 831 * @return Stringified Javascript code that will generate the language string object graph. 832 */ 824 833 public static String getInterfaceStringsAsJavascript(String interfaceName, String lang, String prefix) 825 834 { … … 873 882 if (key.startsWith(prefix)) 874 883 { 875 // Builds the JS object structure we need to access the key. 876 // Also has the side effect of ensuring that any '.' characters in 877 // the key are valid once parsed by the JS engine. 878 buildJSObjectGraph( 879 outputStr, 880 prependToPrefix + "." + key.substring(0, key.lastIndexOf(".")), // Strip the actual key from the path 881 initialisedNodes 882 ); 884 int lastDotIndex = key.lastIndexOf("."); 885 // If this is true, the key is nested under nodes that we might have to construct 886 if (lastDotIndex > 0) { 887 // Builds the JS object structure we need to access the key. 888 // Also has the side effect of ensuring that any '.' characters in 889 // the key are valid once parsed by the JS engine. 890 buildJSObjectGraph( 891 outputStr, 892 prependToPrefix + "." + key.substring(0, lastDotIndex), // Strip the actual key from the path 893 initialisedNodes 894 ); 895 } 883 896 884 897 // get the language dependent value for the key. This will return the english if no value found for the given lang
Note:
See TracChangeset
for help on using the changeset viewer.