| Index: ext/common.js |
| diff --git a/ext/common.js b/ext/common.js |
| index c00cfffac710285aeef7b16823cd952067c7ea4c..f15ec52b616328292e4618691bb784b31d41d3fa 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,36 @@ |
| } |
| }; |
| + let I18n = global.ext._I18n = function(pageName) |
|
Wladimir Palant
2017/03/02 11:20:20
Any reason why _I18n needs to be exported? IMHO th
wspee
2017/03/02 17:13:29
Done, I thought bundling the state with that logic
|
| + { |
| + // Randomize URI to work around bug 719376 |
| + this.stringBundle = Services.strings.createBundle( |
| + "chrome://adblockplus/locale/" + pageName + ".properties?" + Math.random()); |
| + }; |
| + |
| + I18n.prototype = { |
| + getMessage(key) |
| + { |
| + try { |
| + return this.stringBundle.GetStringFromName(key); |
|
Wladimir Palant
2017/03/02 11:20:20
Why did you remove placeholders support? While we
wspee
2017/03/02 17:13:29
Because it didn't work, getI18nMessage never retur
Wladimir Palant
2017/03/06 08:36:40
I see the issue now. I agree, making placeholders
|
| + } |
| + catch(e) |
| + { |
| + // Don't report errors for special strings, these are expected to be |
| + // missing. |
| + if (key[0] != "@") |
| + Cu.reportError(e); |
| + return ""; |
| + } |
| + } |
| + } |
| + |
| + let pageName = "global"; |
| + if (typeof location !== "undefined") |
| + pageName = location.pathname.replace(/.*\//, "").replace(/\..*?$/, ""); |
| + |
| + global.ext.i18n = new I18n(pageName); |
| + |
| if (typeof exports == "object") |
| exports = global.ext; |
| })(this); |