| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 77 |
| 78 /* I18n */ | 78 /* I18n */ |
| 79 | 79 |
| 80 var localeCandidates = null; | 80 var localeCandidates = null; |
| 81 var uiLocale; | 81 var uiLocale; |
| 82 | 82 |
| 83 var getLocaleCandidates = function() | 83 var getLocaleCandidates = function() |
| 84 { | 84 { |
| 85 var candidates = []; | 85 var candidates = []; |
| 86 var defaultLocale = "en_US"; | 86 var defaultLocale = "en_US"; |
| 87 var [language, region] = navigator.language.split("-"); | |
|
Wladimir Palant
2014/04/10 09:18:48
My code was using split("-", 2) - did you remove t
Sebastian Noack
2014/04/10 09:55:22
The third component would be dropped anyway, since
Wladimir Palant
2014/04/10 10:02:09
You are right, I got spoiled by Python. So we woul
Sebastian Noack
2014/04/10 10:12:24
Done.
| |
| 87 | 88 |
| 88 var bits, i; | 89 if (region) |
| 89 for (i = (bits = navigator.language.split("-")).length; i > 0; i--) | 90 candidates.push(language + "_" + region.toUpperCase()); |
| 90 { | |
| 91 var locale = bits.slice(0, i).join("_"); | |
| 92 candidates.push(locale); | |
| 93 | 91 |
| 94 if (locale == defaultLocale) | 92 candidates.push(language); |
| 95 return candidates; | |
| 96 } | |
| 97 | 93 |
| 98 candidates.push(defaultLocale); | 94 if (candidates.indexOf(defaultLocale) == -1) |
| 95 candidates.push(defaultLocale); | |
| 96 | |
| 99 return candidates; | 97 return candidates; |
| 100 }; | 98 }; |
| 101 | 99 |
| 102 var getCatalog = function(locale) | 100 var getCatalog = function(locale) |
| 103 { | 101 { |
| 104 var xhr = new XMLHttpRequest(); | 102 var xhr = new XMLHttpRequest(); |
| 105 | 103 |
| 106 xhr.open("GET", safari.extension.baseURI + "_locales/" + locale + "/messages .json", false); | 104 xhr.open("GET", safari.extension.baseURI + "_locales/" + locale + "/messages .json", false); |
| 107 | 105 |
| 108 try { | 106 try { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 }; | 177 }; |
| 180 | 178 |
| 181 | 179 |
| 182 /* Utils */ | 180 /* Utils */ |
| 183 | 181 |
| 184 ext.getURL = function(path) | 182 ext.getURL = function(path) |
| 185 { | 183 { |
| 186 return safari.extension.baseURI + path; | 184 return safari.extension.baseURI + path; |
| 187 }; | 185 }; |
| 188 })(); | 186 })(); |
| OLD | NEW |