LEFT | RIGHT |
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 Loading... |
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 }()); |
LEFT | RIGHT |