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

Set default language in config file #1561

Closed
vitormfgoncalves opened this issue Jan 3, 2022 · 12 comments
Closed

Set default language in config file #1561

vitormfgoncalves opened this issue Jan 3, 2022 · 12 comments

Comments

@vitormfgoncalves
Copy link

Is your feature request related to a problem?

  • No

Please describe.

  • Its frustrating when your native language is not english and you jump from device to device and have to set preferences again and again.

Describe the solution you'd like

  • An option to set the default language in the config file
@metalheim
Copy link
Contributor

Agree!
Imho it's a bit of an oversight that this hasn't been done before?
And it should be an easy enough change.

@methatronc
Copy link

I'd love to see that as well :)

@deluan deluan closed this as completed in cb3ba23 Sep 27, 2022
@deluan
Copy link
Member

deluan commented Sep 27, 2022

Agree! Imho it's a bit of an oversight that this hasn't been done before? And it should be an easy enough change.

It was not an oversight. I tried it before a couple of times, but because the way React-Admin apps are structured, I'd have to add all languages in the final bundle, which would make the initial load larger and slower.

I tried it again and I think I found a good solution. The new config option is DefaultLanguage, and it has to be the 2 letter ISO code for the language (see the list here: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) one of the file names in the resources/i18n. Ex for Chinese Simplified it has to be zh-Hanz (case sensitive)

Please test it and let me know.

@metalheim
Copy link
Contributor

@deluan tested with latest develop branch ba28e9a.
Works well and as expected.

One thing to add: The new DefaultLanguage setting is case sensitive, only lowercase entries work.
f.e. this works:
DefaultLanguage="pt"
but this doesnt:
DefaultLanguage="PT"

Which is fine, just something to be aware of.

@deluan
Copy link
Member

deluan commented Sep 28, 2022

One thing to add: The new DefaultLanguage setting is case sensitive, only lowercase entries work.

Fixed. Thanks for testing.

@methatronc
Copy link

Just tested with latest docker hub release 0.48.0, it works fine with this in the docker compose :
ND_DEFAULTLANGUAGE: "fr"
Thank you for this 🍺

@SoSolife
Copy link
Contributor

SoSolife commented Oct 18, 2022

One thing to add: The new DefaultLanguage setting is case sensitive, only lowercase entries work.

Fixed. Thanks for testing.

Thanks for adding the option. However for "zh-Hans" it occurs error that translation(id:zh-hans) not found.

@zheyiyuezhuo
Copy link

zheyiyuezhuo commented Oct 29, 2022

One thing to add: The new DefaultLanguage setting is case sensitive, only lowercase entries work.

Fixed. Thanks for testing.

Thanks for adding the option. However for "zh-Hans" it occurs error that translation(id:zh-hans) not found.

图片

You has to be 2 letter ISO code for language . The China`s 2 letter is 'zh' ?

@SoSolife
Copy link
Contributor

SoSolife commented Oct 30, 2022

One thing to add: The new DefaultLanguage setting is case sensitive, only lowercase entries work.

Fixed. Thanks for testing.

Thanks for adding the option. However for "zh-Hans" it occurs error that translation(id:zh-hans) not found.

图片

You has to be 2 letter ISO code for language . The China`s 2 letter is 'zh' ?

Unfortuately, it doesn't define in the resources i18n.
And the author has restore DefaultLanguage case-sensitiveness here.

@YEDEDD
Copy link

YEDEDD commented Feb 5, 2023

I tried ND_DEFAULTLANGUAGE = zh, but the default language was not changed to Chinese, and the others were not successfully changed, and the browser was in seamless mode.

@deluan
Copy link
Member

deluan commented Feb 5, 2023

The DefaultLanguage option has to match one of the file names in the resources/i18n folder as @SoSolife mentioned. So for Chinese simplified it has to be zh-Hans, and it is case sensitive.

It is only used for new sessions. So, if you already logged from a browser, it won't use the default anymore.

If you are still having issues with this, please open a new issue in GitHub, as this one is already closed. Thanks!

@github-actions
Copy link

github-actions bot commented Mar 7, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants