Skip to content
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

Proposal: deprecate i18n.getAcceptLanguages #107

Closed
carlosjeurissen opened this issue Oct 16, 2021 · 4 comments
Closed

Proposal: deprecate i18n.getAcceptLanguages #107

carlosjeurissen opened this issue Oct 16, 2021 · 4 comments
Labels
next manifest version Consider for the next manifest version proposal Proposal for a change or new feature supportive: safari Supportive from Safari topic: localization

Comments

@carlosjeurissen
Copy link
Contributor

carlosjeurissen commented Oct 16, 2021

Currently you can get a list of accepted languages using the i18n.getAcceptLanguages method. This returns an array with the languages found in Accept-Language headers. See MDN doc and Cr doc.

Since the introduction of this API, the web now provides the same using the navigator.languages property. As it seems we want to favor web technologies instead of also providing a webExtension API, I suggest to deprecate i18n.getAcceptLanguages.

One could consider keeping this as it could still be useful in the potentially required service_worker background script. However navigator.languages is now also available in serviceworkers. See MDN doc.

Related issues:
https://bugs.chromium.org/p/chromium/issues/detail?id=101138
https://bugs.chromium.org/p/chromium/issues/detail?id=1258498

@carlosjeurissen carlosjeurissen changed the title Proposal: Deprecated i18n.getAcceptLanguages Proposal: deprecate i18n.getAcceptLanguages Oct 16, 2021
@xeenon xeenon added the documentation Improvements or additions to documentation label Oct 25, 2021
@dotproto dotproto added the next manifest version Consider for the next manifest version label Jul 7, 2022
@xeenon xeenon added proposal Proposal for a change or new feature supportive: safari Supportive from Safari and removed documentation Improvements or additions to documentation labels Aug 31, 2022
@carlosjeurissen
Copy link
Contributor Author

After doing additional tests, I found the following:

If using chrome.webRequest to change the value of the Accept-Language header, both in Firefox and Google Chrome, the value of navigator.languages and the i18n.getAcceptLanguages does not change. Is this intended?

If overwriting the value of navigator.languages in the main world of the page using defineProperty with a getter, the value of navigator.languages or i18n.getAcceptLanguages does not change.

If overwriting the value of navigator.languages in the isolated content script world, the i18n.getAcceptLanguages outputs the original list of acceptLanguages.

This all confirms the equivalence between navigator.languages and i18n.getAcceptLanguages. So this pretty much confirms we can deprecate it if using navigator.languages within the content script does not interfere with the privacy budget of the page in Google Chrome @dotproto .

@hanguokai
Copy link
Member

Chrome is trying Intent to Experiment: Reduce Accept-Language Origin Trial. It will cause navigator.languages only has one language which is the same as navigator.language. I don't think this will soon become a reality, but just in case, i18n.getAcceptLanguages() should be kept for now.

@carlosjeurissen
Copy link
Contributor Author

carlosjeurissen commented Nov 9, 2022

@hanguokai that is a very valid point. I have opened an issue in the relevant github repository to further discuss this:
explainers-by-googlers/reduce-accept-language#6

For now it seems best to keep the i18n.getAcceptLanguages.

@carlosjeurissen carlosjeurissen added topic: localization and removed agenda Discuss in future meetings labels Nov 9, 2022
@carlosjeurissen
Copy link
Contributor Author

In Safari, browser.i18n.getAcceptLanguages returns the full list while navigator.languages returns the restrictive list.

Considering this and previous discussions it is best to keep browser.i18n.getAcceptLanguages around. This will allow extensions to use navigator.languages as it would appear to any other JS code and if it wants the full list, use browser.i18n.getAcceptLanguages. Best of two worlds. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next manifest version Consider for the next manifest version proposal Proposal for a change or new feature supportive: safari Supportive from Safari topic: localization
Projects
None yet
Development

No branches or pull requests

4 participants