Index: chrome/content/ui/i18n.js |
=================================================================== |
--- a/chrome/content/ui/i18n.js |
+++ b/chrome/content/ui/i18n.js |
@@ -82,10 +82,10 @@ |
})(); |
} |
-// Loads and inserts i18n strings into matching elements. Any inner HTML already in the |
-// element is parsed as JSON and used as parameters to substitute into placeholders in the |
-// i18n message. |
-function loadI18nStrings() |
+// Inserts i18n strings into matching elements. Any inner HTML already in the element is |
+// parsed as JSON and used as parameters to substitute into placeholders in the i18n |
+// message. |
+var setElementText = i18n.setElementText = function(element, stringName, arguments) |
Wladimir Palant
2013/09/24 12:45:46
Given that this is loaded into global context I su
|
{ |
function processString(str, element) |
{ |
@@ -104,6 +104,14 @@ |
element.appendChild(document.createTextNode(str)); |
} |
+ while (element.lastChild) |
+ element.removeChild(element.lastChild); |
+ processString(i18n.getMessage(stringName, arguments), element); |
+} |
+ |
+// Loads i18n strings |
+function loadI18nStrings() |
+{ |
var nodes = document.querySelectorAll("[class^='i18n_']"); |
for(var i = 0; i < nodes.length; i++) |
{ |
@@ -117,9 +125,7 @@ |
className = className.animVal; |
var stringName = className.split(/\s/)[0].substring(5); |
- while (node.lastChild) |
- node.removeChild(node.lastChild); |
- processString(i18n.getMessage(stringName, arguments), node); |
+ setElementText(node, stringName, arguments); |
} |
} |