Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java	(revision 35744)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java	(revision 35745)
@@ -828,25 +828,32 @@
 	}
 
-	// generates javascript: 2 arrays are declared and populated with strings that declare variables and assign their values
-	// to be strings loaded from the interface_name.properties file for the language.    
+	/**
+	 * Generates a Javascript object graph to store language strings. Leaf nodes contain the string and the previous node, the key.
+	 * Further preceding nodes denote the prefix of the string (i.e. the gs3 language strings object, which interface they belong to etc.).
+	 * Accessing a language string on a well-formed JS object graph will be similar to this: const myString = gs.text.atea.asr.Title;
+	 * @param interface_name The name of the interface to retrieve language strings for.
+	 * @param lang The language to retrieve.
+	 * @param prefix The prefix to place the language strings under (e.g. atea.asr).
+	 * @param prependToPrefix
+	 * @return Javascript code that will generate the language string object graph.
+	 */
 	public static String getInterfaceStringsAsJavascript(String interface_name, String lang, String prefix, String prependToPrefix)
 	{
 		// now we allow looking for files in the interface's resources folder
-		CustomClassLoader my_loader = new CustomClassLoader(XSLTUtil.class.getClassLoader(), GSFile.interfaceResourceDir(GlobalProperties.getGSDL3Home(), interface_name));
+		CustomClassLoader my_loader = new CustomClassLoader(XSLTUtil.class.getClassLoader(),
+				GSFile.interfaceResourceDir(GlobalProperties.getGSDL3Home(), interface_name));
 		String prefixwithdot = prefix + ".";
-
-		// 1. Generating Javascript of the form:
-		// if(!gs.text) { gs.text = new Array(); }
-		// if(!gs.text.dse) { gs.text.dse = new Array(); }
 
 		StringBuffer outputStr = new StringBuffer();
 		HashSet<String> initialisedDepths = new HashSet<>();
 
+		// Initialise the root prefix object
 		outputStr.append("if(!" + prependToPrefix + ") { ");
-		outputStr.append(prependToPrefix + " = new Array(); ");
+		outputStr.append(prependToPrefix + " = {}; ");
 		outputStr.append("}\n");
 		initialisedDepths.add(prependToPrefix);
 
-		// Handle '.' characters in the prefix. JS identifies these as object accessors, hence requiring a new array for each 'level'.
+		// Initialise the prefix object structure, handling '.' characters.
+		// JS identifies these as property accessors, hence requiring a new object for each 'level'.
 		String currentDepth = prependToPrefix;
 		String[] prefixComponents = prefix.split("\\.");
@@ -856,5 +863,5 @@
 
 			outputStr.append("if(!" + currentDepth + ") { ");
-			outputStr.append(currentDepth + " = new Array(); ");
+			outputStr.append(currentDepth + " = {}; ");
 			outputStr.append("}\n");
 
@@ -862,13 +869,10 @@
 		}
 
-		int foundCount = 0;
-
-		for (String dictName : new String[] { "interface_" + interface_name, "interface_default", "interface_default2" })
-		{
-		  	// get all the keys from the english dictionary as this is a complete set
+		for (String dictName : new String[] { "interface_" + interface_name, "interface_default",
+				"interface_default2" }) {
+			// get all the keys from the english dictionary as this is a complete set
 			Dictionary dict = new Dictionary(dictName, "en", my_loader);
 			Enumeration keys = dict.getKeys();
-			if (keys == null)
-			{
+			if (keys == null) {
 				continue;
 			}
@@ -876,10 +880,8 @@
 			// Get all properties in the language-specific dictionary with the given key prefix
 			// Create Javascript strings of the form:
-			// prependToPrefix.key= "value";\n
-			while (keys.hasMoreElements())
-			{
+			// prefixPath.key= "value";\n
+			while (keys.hasMoreElements()) {
 				String key = (String) keys.nextElement();
-				if (key.startsWith(prefixwithdot))
-				{
+				if (key.startsWith(prefixwithdot)) {
 					String[] keyComponents = key.split("\\.");
 					currentDepth = prependToPrefix + "." + prefix;
@@ -893,5 +895,5 @@
 
 						outputStr.append("if(!" + currentDepth + ") { ");
-						outputStr.append(currentDepth + " = new Array(); ");
+						outputStr.append(currentDepth + " = {}; ");
 						outputStr.append("}\n");
 
@@ -899,5 +901,5 @@
 					}
 
-				  // get the language dependent value for the key. This will return the english if no value found for the given lang
+					// get the language dependent value for the key. This will return the english if no value found for the given lang
 					String value = getInterfaceText(interface_name, dictName, lang, key, null);
 
@@ -910,9 +912,4 @@
 				}
 			}
-
-			if (foundCount > 0)
-			{
-				break;
-			}
 		}
 
