Reputation: 145
I've created a chrome extension for my company using i18n with multiple languages inside the /_locales/ folder. It works great, but since the language system is based on what language is set on the user chrome browser, there're people having one problem.
The extension loads a list of URLs to help moderators answer questions on the company forum. Moderators in the US will load English interface with US URLs (with &lg=en), moderators in Russia will load Russian interface with Russian URLs (with &lg=ru) and so on. The problem is that since the company is global, there are people outside of their countries using notebooks in english, but would require the extension if self to load on German or japanese for instance.
If I create a dropdown menu on the popup window, is it possible to switch extensions language from there? Everything that I read about is always based changing chrome browser settings, and I'm sure a lot of people will have problem doing that, or even people that won't have permission to change the settings.
Hope to have some ideas to achieve that.
Upvotes: 2
Views: 1110
Reputation: 10897
To my knowledge, i18n for extensions depends on Google Chrome's locale and extension's default_locale, while extension itself can't modify Chrome settings.
One workaround would be maintaining the display language by yourself, I mean, something like:
{
'en-us': {},
'en-es': {},
...
}
Or read the specific messages.json through XMLHttpRequest.
When user selects an option, you could change your display language based on above data structure, not depending on extension's existing i18n framework.
Upvotes: 1