Closed stevenatkin closed 9 years ago
If something like that is done, https://github.com/ibm-js/requirejs-dplugins/blob/master/i18n.js must then be changed accordingly so that we get similar locale resolution when loading resource bundles to avoid discrepancies.
We should also probably share the code that pick the default locales between ecma-402 and requirejs-dplugins so that any subsequent changes is shared across the two projects.
Note how that this change would make the behavior inconsistent across browsers which I'm not 100% sure his a good idea (knowing that is someone want to use navigator.languages he can already perfectly use it I suppose so it is not like if that was blocking them?)
As I am new in the g11n world, my biggest question here is how locales are prioritized between computed fallback (like fr-fr
fall back to fr
) and user specified fallback (if navigator.languages
is ['fr-fr', 'pt']
).
With the previous example (navigator.languages = ['fr-fr', 'pt']
), if only fr
and pt
are available, which locale should be chosen ?
Is there a specification about that ?
No specification, but a best current practice (becoming a de facto standard), BCP 47, that you can find at http://tools.ietf.org/html/bcp47. Look for Lookup.
Ok, so if I understand the BCP correctly, in the previous example the locale should be fr
right ?
Correct. However, there are some special cases that are not as straightforward, such as Portuguese or Chinese, or as soon as you have a different script.
Ok, I think I am lacking some expertise here so I'll let @JCEmmons look into this.
Let's see if we can use the navigator.languages list from Mozilla and Chrome. The navigator.languages list is the same as the list of languages in the HTTP Accept-Language header.