Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/ui/i18n.js

Issue 11790013: Expose string insertion functionality from i18n.js to public (Closed)
Patch Set: Created Sept. 20, 2013, 3:46 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld