Search code examples
javascriptgoogle-chrome-extension

Chrome extension how to change language?


for example in my manifest.json there is a param:

  "default_locale": "en"

the question is how can I dynamically change the language in the javascript code?

can't find any examples on the docs about specific methods...

also my data is binded like this:

<div data-l10n-id="key_download"></div>

it is dynamically parsed in the html, but how can I change the language it chooses?


Solution

  • The point of the built-in chrome.i18n API is to make extensions match the UI language of the browser so there's no chrome API way to change it programmatically, you'll have to implement it yourself or use one of the existing js libraries.

    Read the official chrome.i18n documentation for more details and examples of how to facilitate testing of your extension with different UI languages of the browser.