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

Not possible to select English anymore, if system locale is non-English #1357

Closed
ripcurlx opened this issue Feb 14, 2018 · 6 comments
Closed
Assignees
Labels

Comments

@ripcurlx
Copy link
Contributor

Since the PR (#1313) was merged into master, I'm not able to select English anymore in the Settings screen. It always defaults to my system locale (de_AT in my case). I'm able to select any other locale (e.g. Spanish), which works after re-start. But whenever I select English it displays the To apply the language change to all screens requires a restart. in my systems language (de) and not in English. When restarted English is selected in the Settings, but everything is in German.

@ripcurlx
Copy link
Contributor Author

It has something to do with the default locale setting. I just made a quick test and added a new property file displayStrings_en.properties with the English translations in it and it works.
When
resourceBundle = ResourceBundle.getBundle("i18n.displayStrings", newValue, new UTF8Control());
is called it will always return the german resource bundle no matter if "de_AT" or "en_AT" is used.

@ManfredKarrer
Copy link
Contributor

Yes seems the setting of the default local will overwrite your settings.
@blabno Can you have a look to fix that?

@blabno
Copy link

blabno commented Feb 14, 2018 via email

@blabno
Copy link

blabno commented Feb 19, 2018

After looking at the way the ResourceBundle work we should duplicate default displayStrings.properties and name it displayStrings_en.properties.

Here's how it works.

Assuming you have selected en language.
First ResourceBundle tries to find file displayStrings_en.properties. If the file cannot be found then
RB checks what is default locale (looks at env variables). In case your env locale is de and there is a file
displayStrings_de.properties then that file is going to be loaded.
displayStrings.properties is used only if you do not have a file with suffix matching requested or env locale.

What do you think @ManfredKarrer ? Should we duplicate?

@blabno
Copy link

blabno commented Feb 19, 2018

Alternatively we could add

if ("en".equalsIgnoreCase(newValue.getLanguage()))
  newValue = Locale.ROOT;

before

resourceBundle = ResourceBundle.getBundle("i18n.displayStrings", newValue, new UTF8Control());

@ManfredKarrer
Copy link
Contributor

Prefer the second approach with Locale.ROOT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants