Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposal: i18n-system-languages #569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Proposal: i18n-system-languages #569
Changes from all commits
d078e457ed4c53916f91d30fbed61339056b7781f4ae8e4e20c352e815fde771bf297cb9ab150da34a81610770038e9f394eb3df1280efb590dec9b1d995e989f08b376acf81395c02e07b64c9e8ae3a97e3c88f64b942d42f71ae7ac0a42dded68e235bcc6a3015a0dfdc23eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Proposal: i18n.getPreferredSystemLanguages() and i18n.getSystemUILanguage()
Summary
Allows getting the language(s)/locale(s) of your operating system as a BCP47 language tag
Document Metadata
Author: carlosjeurissen
Sponsoring Browser: Safari
Created: 2024-03-18
Related Issues: #252 https://bugzilla.mozilla.org/show_bug.cgi?id=1888486
Motivation
Objective
Allow extensions to display UI in the user's system locale(s), even when this is distinct from the browser's UI locale (which is restricted to locales supported by the browser).
Use Cases
Extension authors might want to obtain the locale used by the user agent's host environment in order to format values (such as numbers, dates, and so forth) or do other locale-affected operations (such as list sorting) according to expectations of the user. For example, formatting the date
2024-06-15varies betweenen-US(6/15/2024) anden-GB(15/6/2024), whereasi18n.getUILanguagemight return onlyen(English).Extension authors might want to obtain the locale used by the user agent's host environment to better match the runtime environment's localization. For example, the operating system might be running in
ff-NG(Fulani as used in Nigeria), but the user agent might not be localized for this locale and returnen(English) fori18n.getUILanguage.Extension authors might want to obtain the locale used by the user agent's host environment in order to get the locales in it's purest form. For example, the operating system might be running in
es-ARand a browser's closest equivalent ises-419. Having access toes-ARallows extension authors to provide better translations for all users.Known Consumers
Language-related extensions and extensions wanting to match the locale of the operating system more closely independent of the locale of the browser.
Specification
Schema
i18n.getPreferredSystemLanguages()would asynchronously return a language priority list (ordered list of BCP47 language tag. This is similar toi18n.getAcceptLanguages(), with the difference that the priority list is configured by the user in the OS and the method would not add less specific language tags in place.{ "name": "getPreferredSystemLanguages", "type": "function", "description": "Gets the preferred locales of the operating system. This is different from the locales set in the browser; to get those, use $(ref:i18n.getAcceptLanguages).", "parameters": [], "returns_async": { "name": "callback", "parameters": [{ "name": "languages", "type": "array", "items": {"$ref": "LanguageCode"}, "description": "Array of LanguageCode" }] } }i18n.getSystemUILanguage()would asynchronously return a BCP47 language tag likei18n.getUILanguage()does right now.The returned language tag can be different from the first entry returned by getPreferredSystemLanguages as the operating system could not support all languages specified by the user for its user interface.
It would follow the following signature for i18n.json:
{ "name": "getSystemUILanguage", "type": "function", "description": "Gets the current UI locale of the Operating System. This is different from $(ref:i18n.getUILanguage) which returns the UI locale of the web browser.", "parameters": [], "returns_async": { "name": "callback", "parameters": [{ "type": "string", "description": "A BCP47 language tag such as en-US or pt-BR." }] } }New Permissions
As
browser.i18n.getUILanguage()does not require a permission,browser.i18n.getSystemUILanguageandbrowser.i18n.getPreferredSystemLanguagesalso should not.Manifest File Changes
No new manifest fields
Security and Privacy
Exposed Sensitive Data
The locale(s) of the system will be purposely exposed.
Alternatives
Existing Workarounds
Currently, if an extension wants to offer locales outside not localised for by the browser, it must do so by presenting a user-facing options page. However, currently there is no way to reasonably detect a language code outside of the browser's UI language with existing APIs.
Open Web API
To combat fingerprinting, this should not be an Open Web API, like
browser.i18n.getUILanguageis not.Uh oh!
There was an error while loading. Please reload this page.