Index: safari/ext/common.js |
=================================================================== |
--- a/safari/ext/common.js |
+++ b/safari/ext/common.js |
@@ -84,18 +84,16 @@ |
{ |
var candidates = []; |
var defaultLocale = "en_US"; |
+ 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.
|
- var bits, i; |
- for (i = (bits = navigator.language.split("-")).length; i > 0; i--) |
- { |
- var locale = bits.slice(0, i).join("_"); |
- candidates.push(locale); |
+ if (region) |
+ candidates.push(language + "_" + region.toUpperCase()); |
- if (locale == defaultLocale) |
- return candidates; |
- } |
+ candidates.push(language); |
- candidates.push(defaultLocale); |
+ if (candidates.indexOf(defaultLocale) == -1) |
+ candidates.push(defaultLocale); |
+ |
return candidates; |
}; |