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

Side by Side Diff: ext/common.js

Issue 29569659: Issue 4580 - Replace ext.i18n.getMessage with i18n.getMessage (Closed) Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Rebase Created Oct. 9, 2017, 5:19 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « desktop-options.js ('k') | i18n.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 (function() 20 (function()
21 { 21 {
22 if (typeof chrome == "undefined")
23 window.chrome = {};
24
22 if (typeof ext == "undefined") 25 if (typeof ext == "undefined")
23 window.ext = {}; 26 window.ext = {};
24 27
25 function Page(source) 28 function Page(source)
26 { 29 {
27 this._source = source; 30 this._source = source;
28 } 31 }
29 Page.prototype = 32 Page.prototype =
30 { 33 {
31 sendMessage(message) 34 sendMessage(message)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return; 154 return;
152 155
153 let rawCatalog = JSON.parse(xhr.responseText); 156 let rawCatalog = JSON.parse(xhr.responseText);
154 for (let msgId in rawCatalog) 157 for (let msgId in rawCatalog)
155 { 158 {
156 if (!(msgId in catalog)) 159 if (!(msgId in catalog))
157 catalog[msgId] = parseMessage(rawCatalog[msgId]); 160 catalog[msgId] = parseMessage(rawCatalog[msgId]);
158 } 161 }
159 }; 162 };
160 163
161 window.ext.i18n = { 164 chrome.i18n = {
Sebastian Noack 2017/10/09 18:43:54 Shouldn't this rather be browser.i18n, now where w
Manish Jethani 2017/10/09 18:47:02 Yes, assuming that one lands first.
162 locale: locales[0], 165 getUILanguage()
166 {
167 return locales[0].replace(/_/g, "-");
168 },
163 getMessage(msgId, substitutions) 169 getMessage(msgId, substitutions)
164 { 170 {
165 while (true) 171 while (true)
166 { 172 {
167 let message = catalog[msgId]; 173 let message = catalog[msgId];
168 if (message) 174 if (message)
169 { 175 {
170 let text = message[0]; 176 let text = message[0];
171 let placeholders = message[1]; 177 let placeholders = message[1];
172 178
173 if (!(substitutions instanceof Array)) 179 if (!(substitutions instanceof Array))
174 substitutions = [substitutions]; 180 substitutions = [substitutions];
175 181
176 for (let i = 0; i < placeholders.length; i++) 182 for (let i = 0; i < placeholders.length; i++)
177 text = replacePlaceholder(text, placeholders[i], substitutions[i]); 183 text = replacePlaceholder(text, placeholders[i], substitutions[i]);
178 184
179 return text; 185 return text;
180 } 186 }
181 187
182 if (locales.length == 0) 188 if (locales.length == 0)
183 return ""; 189 return "";
184 190
185 let locale = locales.shift(); 191 let locale = locales.shift();
186 readCatalog(locale, "common.json"); 192 readCatalog(locale, "common.json");
187 readCatalog(locale, catalogFile); 193 readCatalog(locale, catalogFile);
188 } 194 }
189 } 195 }
190 }; 196 };
191 }()); 197 }());
OLDNEW
« no previous file with comments | « desktop-options.js ('k') | i18n.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld