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

Unified Diff: ext/content.js

Issue 29376555: [adblockplus] Issue 4915 - Expose ext.i18n for background pages (Closed)
Patch Set: Removed I18n class Created March 2, 2017, 5:04 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 | « ext/common.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/content.js
diff --git a/ext/content.js b/ext/content.js
index 3b84e05286c6a3261f8b3f7aea09d00ba69df177..b2b956a1b11d8908e088383db34e699f263e4789 100644
--- a/ext/content.js
+++ b/ext/content.js
@@ -79,65 +79,4 @@
}
};
- /* i18n */
- global.ext.i18n = (function()
- {
- var pageName = location.pathname.replace(/.*\//, "").replace(/\..*?$/, "");
-
- // Randomize URI to work around bug 719376
- var stringBundle = Services.strings.createBundle("chrome://adblockplus/locale/" + pageName +
- ".properties?" + Math.random());
-
- function getI18nMessage(key)
- {
- return {
- "message": stringBundle.GetStringFromName(key)
- };
- }
-
- function getText(message, args)
- {
- var text = message.message;
- var placeholders = message.placeholders;
-
- if (!args || !placeholders)
- return text;
-
- for (var key in placeholders)
- {
- var content = placeholders[key].content;
- if (!content)
- continue;
-
- var index = parseInt(content.slice(1), 10);
- if (isNaN(index))
- continue;
-
- var replacement = args[index - 1];
- if (typeof replacement === "undefined")
- continue;
-
- text = text.split("$" + key + "$").join(replacement);
- }
- return text;
- }
-
- return {
- getMessage: function(key, args)
- {
- try{
- var message = getI18nMessage(key);
- return getText(message, args);
- }
- catch(e)
- {
- // Don't report errors for special strings, these are expected to be
- // missing.
- if (key[0] != "@")
- Cu.reportError(e);
- return "";
- }
- }
- };
- })();
})(this);
« no previous file with comments | « ext/common.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld