1

My extension has two locales in the _locales folder, it has ja and ru.

The manifest.json has "default_locale": "ru".

But now let's say for example a Spanish user installs my extension, their chrome.i18n.getUILanguage() and chrome.i18n.getAcceptLanguages() results in ['es', 'es-ES'].

Is there a way I can determine what locale the browser is displaying my extension material in?

EDIT - What i currently do:

I XHR the _locales directory (make sure to have the ending / otherwise XHR fails) I then get all the directories. Then i find a common key among all files that has a unique value across all files. Then I do chrome.i18n.getMessage(key) and see which directories message.json gave that. It works but I just thought there would be a built in way.

Noitidart
  • 35,443
  • 37
  • 154
  • 323
  • 1
    Check this [SO question](http://stackoverflow.com/questions/1043339/javascript-for-detecting-browser-language-preference) if it can help you. – KENdi Nov 24 '16 at 09:54
  • Thanks @KENdi I edited the question to show the current way I do it. That SO question doesnt help too much. – Noitidart Nov 24 '16 at 10:12
  • Add `chrome.i18n.getMessage("@@ui_locale")` to the list of things that don't work.. – Xan Nov 24 '16 at 11:17

0 Answers0