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

Add language selection option to settings #2925

Merged
merged 1 commit into from
Nov 22, 2019

Conversation

DasSkelett
Copy link
Member

@DasSkelett DasSkelett commented Nov 21, 2019

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 is null.

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.
grafik
grafik

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).
grafik

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.
grafik

When the user opens the settings, the current language will be selected by default in the combobox.
grafik

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.

@DasSkelett DasSkelett added Enhancement New features or functionality GUI Issues affecting the interactive GUI labels Nov 21, 2019
@HebaruSan
Copy link
Member

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.

image

image

GUI/SettingsDialog.resx Outdated Show resolved Hide resolved
@DasSkelett
Copy link
Member Author

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.
@DasSkelett
Copy link
Member Author

DasSkelett commented Nov 22, 2019

Rebased to remove the resizing stuff, and changed the Requires Restart to lower case.
I moved the new check in GUIConfig.LoadOrCreateConfiguration() to create a new config if the file exists but is empty to this commit.

Copy link
Member

@HebaruSan HebaruSan left a 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!

@HebaruSan HebaruSan merged commit 326ecda into KSP-CKAN:master Nov 22, 2019
@DasSkelett DasSkelett deleted the feature/languageSelection branch November 22, 2019 20:15
@DasSkelett DasSkelett added the i18n Issues regarding the internationalization of CKAN and PRs that need translating label Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New features or functionality GUI Issues affecting the interactive GUI i18n Issues regarding the internationalization of CKAN and PRs that need translating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants