@@ 1821-1843 (lines=23) @@ | ||
1818 | // pick the locale from the array |
|
1819 | // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each |
|
1820 | // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root |
|
1821 | function chooseLocale(names) { |
|
1822 | var i = 0, j, next, locale, split; |
|
1823 | ||
1824 | while (i < names.length) { |
|
1825 | split = normalizeLocale(names[i]).split('-'); |
|
1826 | j = split.length; |
|
1827 | next = normalizeLocale(names[i + 1]); |
|
1828 | next = next ? next.split('-') : null; |
|
1829 | while (j > 0) { |
|
1830 | locale = loadLocale(split.slice(0, j).join('-')); |
|
1831 | if (locale) { |
|
1832 | return locale; |
|
1833 | } |
|
1834 | if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { |
|
1835 | //the next array item is better than a shallower substring of this one |
|
1836 | break; |
|
1837 | } |
|
1838 | j--; |
|
1839 | } |
|
1840 | i++; |
|
1841 | } |
|
1842 | return globalLocale; |
|
1843 | } |
|
1844 | ||
1845 | function loadLocale(name) { |
|
1846 | var oldLocale = null; |
@@ 1085-1107 (lines=23) @@ | ||
1082 | // pick the locale from the array |
|
1083 | // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each |
|
1084 | // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root |
|
1085 | function chooseLocale(names) { |
|
1086 | var i = 0, j, next, locale, split; |
|
1087 | ||
1088 | while (i < names.length) { |
|
1089 | split = normalizeLocale(names[i]).split('-'); |
|
1090 | j = split.length; |
|
1091 | next = normalizeLocale(names[i + 1]); |
|
1092 | next = next ? next.split('-') : null; |
|
1093 | while (j > 0) { |
|
1094 | locale = loadLocale(split.slice(0, j).join('-')); |
|
1095 | if (locale) { |
|
1096 | return locale; |
|
1097 | } |
|
1098 | if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { |
|
1099 | //the next array item is better than a shallower substring of this one |
|
1100 | break; |
|
1101 | } |
|
1102 | j--; |
|
1103 | } |
|
1104 | i++; |
|
1105 | } |
|
1106 | return null; |
|
1107 | } |
|
1108 | ||
1109 | function loadLocale(name) { |
|
1110 | var oldLocale = null; |