-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Add language selection option to settings #2925
Add language selection option to settings #2925
Conversation
The resizing/scrolling is not working at all well in my testing. It defaults to a bad size, it doesn't fill the space if I make it larger, it chops off the left part of the window without being able to scroll back sometimes, etc. I think we would receive a lot of complaints if we shipped it like this. If you want to do something to fit smaller screens, what about a tab list at the left, with one tab per panel? It's a pretty common UI pattern for settings windows nowadays. |
Then I'll remove the resizing stuff from this PR for now, and maybe try that in another one. |
Add a dropdown ComboBox for language selection in the settings. The choosen language is saved in the Core's configuration (JSON/Win32Registry). By default it is `null`, until either CKAN is started in a language that is supported by CKAN (e.g. via `LC_ALL` env var or simple OS settings), or the user manually selects a language in the settings. The supported languages are saved in `CKAN(-Core).Utilities.AvailableLanguages`. Also added a check in `LoadOrCreateConfiguration()`, so that it'll create a new configuration if the file exists but is empty.
2506ce0
to
326ecda
Compare
Rebased to remove the resizing stuff, and changed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, users will be glad to have this!
Motivation
Quite a few forum users asked for an option to change the language in CKAN after the release that introduced localization.
Changes
I added a combobox to the settings that allows changing the language.
The selected language is saved in the "Core's" configuration (so the JSON config and also the Win32Registry, although the second one is no longer in use, but it was easy and fast to do).
It is saved in the RFC 5646 / RFC 4647 format, the same that is used as appendix for the resource files (=
de-DE
,en-US
,en-GB
).How it works:
By default, the
Language
field in the config isnull
.First start / no language saved in config
When the CKAN GUI starts, it checks the currently saved language. If it's null, it'll try to save whatever language CKAN was launched in the config.
If the launch language is not one that is explicitly supported by CKAN, the config value stays
null
, and the GUI continues in the launch language.Now when the user opens the settings, he will see a "blank" combobox. When he clicks it and selects on of the currently three supported languages, it is saved in the config. A restart is required to apply the languages (I didn't want to bother with re-initializing all GUI controls, and nothing wrong with a restart of the client).
Subsequent starts / language set in the config
When CKAN starts and finds a language set in the config, it'll apply it as
System.Threading.Thread.CurrentUICulture
, before any controls are initialized.When the user opens the settings, the current language will be selected by default in the combobox.
The CKAN-supported languages are accessible via
string[] CKAN.Utilities.AvailableLanguages
.I also added an additional check in
GUIConfig.LoadOrCreateConfiguration()
to create a new config if the file exists but is empty.