-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Introduction
Historically, browser extensions have been using language tags with two different syntaxes.
- Using a hyphen, I.E.
en-US. This is the proper language tag format as defined in BCP47 - Using an underscore, I.E.
en_US. This is similar to POSIX, ICU and ISO/IEC 15897.
Both syntaxes have been used and supported with mixed support in different areas of the extensions. Support varies per API and browser. This WECG issue covers those areas in an attempt to come to alignment.
_locales directory
In most documentation, locale directories are supposed to use the underscore variant.
Currently this is a requirement for Chrome while Firefox seems to also support the hyphen -.
Going forward, unless there is a clear reason why underscores should be used my proposal would be to start add support for the proper BCP47 tags and disallow the use of underscores in mv4.
manifest.json default_locale
Following documentation, default_locale is supposed to be using the subdirectory name of _locales.
Currently chrome requires the use of the underscore, while Firefox supports both a hyphen and an underscore.
Going forward I suggest we keep this documentation and follow the switch to BCP47 as mentioned in _locales above.
i18n.getUILanguage
Following documentation, this returns a BCP47 language tag. Historically before version 55, Firefox used to return the underscore variation. I suggest we keep this as is.
i18n.getMessage('@@ui_locale')
This is defined as returning the current locale. In Chrome it returns the underscore variant. While in Firefox, probably since version 56, it returns the BCP47 tag.
Going forward, I suggest this to be equal to the variation used in _locales as it could be used to fetch the messages.json file.
Final words
Basically the goal is to align the behaviour across browsers. My opinion would be to always use BCP47. However this comes with a transitional cost which I believe this is worth it. Alternatively we agree for example to use the underscore only for files. However we still need to agree on default_locale and what is returned by @@ui_locale.
Related: #131