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

Adding support for selecting language dynamically #345

Merged
merged 5 commits into from
Apr 21, 2021

Conversation

ldebello
Copy link
Contributor

Motivation

Following the idea of supporting i18n I think it would be good to select the language from the UI directly.

Note: This is work in progress and I am sending the PR to check if this is something you want to support and if you agree on the approach if you confirm this I can continue working in the final solution and make the remaining components bound to the resource factory

Solution based on https://stackoverflow.com/questions/32464974/javafx-change-application-language-on-the-run

Proposal

Adding a combobox with the available language and instead of setting text directly into components make they bound to a resource factory so a change in the resource factory will make them to update.

Initial UI

image

After changing language

image

Only "Start" translate to "Empezar" because that is the only translation available.

Changes

  • Add label for language combobox
  • Add combobox
  • Comment out setText update because this will not work with bound properties

@ldebello ldebello mentioned this pull request Apr 19, 2021
@chriswhocodes
Copy link
Member

Hi @ldebello this looks like a nice clean way to switch languages. Do you think it will work (binding) for all components that can contain translated text (e.g. buttons, labels, perhaps table column headers) ?

I'm happy for you to continue on this path and I will wait until there is a working prototype before I make any more i18n changes so that we don't conflict.

Thank you and to all the translators for your help! I will add your names to the POM as contributors.

@ldebello
Copy link
Contributor Author

Hi @ldebello this looks like a nice clean way to switch languages. Do you think it will work (binding) for all components that can contain translated text (e.g. buttons, labels, perhaps table column headers) ?

I'm happy for you to continue on this path and I will wait until there is a working prototype before I make any more i18n changes so that we don't conflict.

Thank you and to all the translators for your help! I will add your names to the POM as contributors.

Hi, it should work for all the components I will continue working on this and let you know when it is ready for your review.

@ldebello ldebello changed the title Adding support for selecting language dynamically [WIP] Adding support for selecting language dynamically Apr 21, 2021
@ldebello
Copy link
Contributor Author

Hi @chriswhocodes the PR is ready for review.

Changes

  • Support for dynamic changing text and tooltip in textbox and checkbox
  • Support for dynamic changes in table column
  • Support for parameters in i18n messages each position is defined as $(index) and the UI code shares the N bindings to check (so a change in any binding recompute the text)
  • Changing ch file to zh which seems is support by intellij and lang zh is simplified chinese

@chriswhocodes chriswhocodes merged commit 747a500 into AdoptOpenJDK:master Apr 21, 2021
@chriswhocodes
Copy link
Member

Awesome work @ldebello ! I've merged your patch and will start to replace some more of the UI string literals with properties in the lang.properties file :)

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

Successfully merging this pull request may close these issues.

2 participants