| Index: safari/ext/common.js |
| =================================================================== |
| --- a/safari/ext/common.js |
| +++ b/safari/ext/common.js |
| @@ -85,17 +85,18 @@ |
| var candidates = []; |
| var defaultLocale = "en_US"; |
| - var bits, i; |
| - for (i = (bits = navigator.language.split("-")).length; i > 0; i--) |
| - { |
| - var locale = bits.slice(0, i).join("_"); |
| - candidates.push(locale); |
| + // e.g. "en-us" -> "en", "us", if there are multiple dashes, the part |
| + // after the second dash will be dropped, but that case doesn't exist |
|
Wladimir Palant
2014/04/10 10:17:48
Nit: use "ja-jp-mac" as example? That case does ex
Sebastian Noack
2014/04/10 10:33:28
Done.
|
| + var [language, region] = navigator.language.split("-"); |
| - if (locale == defaultLocale) |
| - return candidates; |
| - } |
| + if (region) |
| + candidates.push(language + "_" + region.toUpperCase()); |
| - candidates.push(defaultLocale); |
| + candidates.push(language); |
| + |
| + if (candidates.indexOf(defaultLocale) == -1) |
| + candidates.push(defaultLocale); |
| + |
| return candidates; |
| }; |