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

Delta Between Two Patch Sets: polyfill.js

Issue 29573083: Issue 5028 - Use browser namespace (Closed) Base URL: https://hg.adblockplus.org/adblockplusui/
Left Patch Set: Move i18n code into polyfill.js Created Oct. 11, 2017, 11:27 a.m.
Right Patch Set: Add polyfill.js to README.md Created Oct. 17, 2017, 12:35 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « mobile-options.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 browser == "undefined") 22 window.browser = {};
23 window.browser = {};
24 23
25 /* I18n */ 24 /* I18n */
26 25
27 let getLocaleCandidates = function(selectedLocale) 26 let getLocaleCandidates = function(selectedLocale)
28 { 27 {
29 let candidates = []; 28 let candidates = [];
30 let defaultLocale = "en-US"; 29 let defaultLocale = "en_US";
31 30
32 // e.g. "ja-jp-mac" -> "ja-JP", note that the part after the second 31 // e.g. "ja-jp-mac" -> "ja_JP", note that the part after the second
33 // dash is dropped, since we only support language and region 32 // dash is dropped, since we only support language and region
34 let parts = selectedLocale.split("-"); 33 let parts = selectedLocale.split("-");
35 let language = parts[0]; 34 let language = parts[0];
36 let region = (parts[1] || "").toUpperCase(); 35 let region = (parts[1] || "").toUpperCase();
37 36
38 if (region) 37 if (region)
39 candidates.push(language + "-" + region); 38 candidates.push(language + "_" + region);
40 39
41 candidates.push(language); 40 candidates.push(language);
42 41
43 if (candidates.indexOf(defaultLocale) == -1) 42 if (candidates.indexOf(defaultLocale) == -1)
44 candidates.push(defaultLocale); 43 candidates.push(defaultLocale);
45 44
46 return candidates; 45 return candidates;
47 }; 46 };
48 47
49 let selectedLocale = window.navigator.language; 48 let selectedLocale = window.navigator.language;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (locales.length == 0) 131 if (locales.length == 0)
133 return ""; 132 return "";
134 133
135 let locale = locales.shift(); 134 let locale = locales.shift();
136 readCatalog(locale, "common.json"); 135 readCatalog(locale, "common.json");
137 readCatalog(locale, catalogFile); 136 readCatalog(locale, catalogFile);
138 } 137 }
139 } 138 }
140 }; 139 };
141 }()); 140 }());
LEFTRIGHT

Powered by Google App Engine
This is Rietveld