diff options
author | arv@google.com <arv@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 23:08:55 +0000 |
---|---|---|
committer | arv@google.com <arv@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 23:08:55 +0000 |
commit | 4c8a86f8e37d96d6e0836215665698ad42577de4 (patch) | |
tree | 314ba04c72d74ed505c8163b002606601b89772f /chrome/browser/resources/local_strings.js | |
parent | 4b87e474248a7d635df9b48983c89f61f7f6d570 (diff) | |
download | chromium_src-4c8a86f8e37d96d6e0836215665698ad42577de4.zip chromium_src-4c8a86f8e37d96d6e0836215665698ad42577de4.tar.gz chromium_src-4c8a86f8e37d96d6e0836215665698ad42577de4.tar.bz2 |
Make LocalStrings work without manipulating the DOM.
BUG=None
TEST=Make sure that localized text on NTP, History and Downloads still
look the same.
Review URL: http://codereview.chromium.org/125076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18551 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/local_strings.js')
-rw-r--r-- | chrome/browser/resources/local_strings.js | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/chrome/browser/resources/local_strings.js b/chrome/browser/resources/local_strings.js index a7ea225..caeea36 100644 --- a/chrome/browser/resources/local_strings.js +++ b/chrome/browser/resources/local_strings.js @@ -1,21 +1,10 @@ -///////////////////////////////////////////////////////////////////////////////
-// localStrings:
/**
- * We get strings into the page by using JSTemplate to populate some elements
- * with localized content, then reading the content of those elements into
- * this global strings object.
- * @param {Node} node The DOM node containing all our strings.
+ * The local strings get injected into the page usig a varaible named
+ * {@code templateData}. This class provides a simpler interface to access those
+ * strings.
+ * @constructor
*/
-function LocalStrings(node) {
- this.strings_ = {};
-
- var children = node.children;
- for (var i = 0, child; child = children[i]; i++) {
- var id = child.id;
- if (id) {
- this.strings_[id] = child.innerHTML;
- }
- }
+function LocalStrings() {
}
/**
@@ -24,7 +13,7 @@ function LocalStrings(node) { * @return {string} The localized string.
*/
LocalStrings.prototype.getString = function(s) {
- return this.strings_[s] || '';
+ return templateData[s] || '';
};
/**
@@ -35,5 +24,5 @@ LocalStrings.prototype.getString = function(s) { * @return {string} The formatted string.
*/
LocalStrings.prototype.formatString = function(s, d) {
- return this.getString(s).replace(/\%s/, d);
-};
\ No newline at end of file + return this.getString(s).replace(/%s/, d);
+};
|