Index: ext/common.js |
diff --git a/ext/common.js b/ext/common.js |
index c00cfffac710285aeef7b16823cd952067c7ea4c..ae0a12ca9a466bcd1424d37759ca6181a920264f 100644 |
--- a/ext/common.js |
+++ b/ext/common.js |
@@ -17,6 +17,10 @@ |
(function(global) |
{ |
+ const Cu = Components.utils; |
+ |
+ let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
+ |
if (!global.ext) |
global.ext = {}; |
@@ -82,6 +86,30 @@ |
} |
}; |
+ let pageName = "global"; |
+ if (typeof location !== "undefined") |
+ pageName = location.pathname.replace(/.*\//, "").replace(/\..*?$/, ""); |
+ |
+ let stringBundle = Services.strings.createBundle( |
+ "chrome://adblockplus/locale/" + pageName + ".properties?" + Math.random()); |
+ |
+ global.ext.i18n = { |
+ getMessage(key, args) |
+ { |
+ try { |
+ return stringBundle.GetStringFromName(key); |
+ } |
+ catch(e) |
+ { |
+ // Don't report errors for special strings, these are expected to be |
+ // missing. |
+ if (key[0] != "@") |
+ Cu.reportError(e); |
+ return ""; |
+ } |
+ } |
+ }; |
+ |
if (typeof exports == "object") |
exports = global.ext; |
})(this); |