#1936: Improve localization of gui#1979
Conversation
- Added testing class for modals
- Added logging to IdeGuiStateManager. - Added functionality, that selecting a different project now switches the IdeContext to the new project.
- Added testing class for modals
- Added logging to IdeGuiStateManager. - Added functionality, that selecting a different project now switches the IdeContext to the new project.
…t-for-gui' into devonfw#1785-implement-modals-in-idecontext
- Added functionality, that selecting a different project now switches the IdeContext to the new project.
…plementation' into devonfw#1802-state-management-implementation
…r other ui feature branches
- added DI for IdeGuiStateManager.switchContext
…reading the list of workspaces/projects instead of reading those from the UI
…nager, when switchContext(Path rootDirectory, ...) is called.
This reverts commit 6f92d93.
…plementation' into devonfw#1802-state-management-implementation
…tateManager is now set when calling getInstance(), allowing us to provide a getInstance() method with a DI parameter
… getInstance()) (see previous commit)
…can be extended by tests
…plementation' into devonfw#1802-state-management-implementation
laim2003
left a comment
There was a problem hiding this comment.
looks good! just left some thoughts😊
…/1936-improve-localization-of-gui"
| @@ -0,0 +1,17 @@ | |||
| # IDEasy GUI - English (default) Translation File | |||
There was a problem hiding this comment.
In cli we named the folder nls for "Native Language Support".
For homogeneity, it would be nice to have both folder named the same.
If the team better understands localization we can also change nls but it is short and maybe more speaking than l10n what other projects use as shortcut for localization.
There was a problem hiding this comment.
So should localization be changed to nls , and accordingly the usage of the service also to nls ?
hohwille
left a comment
There was a problem hiding this comment.
@KarimALotfy thanks for your PR.
Very nice that you figured out how to do NLS (i18n and l10n) with JavaFx (using Locale, ResourceBundle and the % syntax in fxml files). Great that you also added a proper JUnit test and some advanced features. 👍
I left quite some comments for rework.
In some cases you may decide to go for more KISS and keep some advanced features out of this first PR and introduce in a later improving PR after this one is merged or you should go for the full solution if you already start it.
- Generalize localization keys in the `.properties` files - Detect available resource bundles automatically instead of hardcoding languages - Persist the selected language in `~/.ide/ide.properties` using `IDE_LOCALE` - Load and apply the persisted locale during GUI initialization - Remove `updateTexts()` from `MainController` - Reload the app after each language selection to apply localization changes - Refactor tests to match the updated localization flow
…le discovery -Scan localization/messages_*.properties across classpath entries (directories and JARs) at runtime instead of checking against a fixed language array. - Add tests covering directory scan, JAR scan, and content-agnostic detection.
…/1936-improve-localization-of-gui
…thub.com/KarimALotfy/IDEasy into feature/1936-improve-localization-of-gui
hohwille
left a comment
There was a problem hiding this comment.
@KarimALotfy thanks for your rework. Great that you figured the proper solution to find the locales from the classpath and reload the GUI elegantly after language change, etc. Great work 👍
Still I left some comments for improvement. Please have a look. When resolved, we can finally merge.
-Persistence to use existing variable IDE_OPTIONS (-Duser.lang=) instead of the new unneeded variable IDE_LOCALE
-Removed unneccessary UTF8Control
…njection
Remove static getInstance/resetInstance methods; LocalizationService is now
instantiated in App and passed to MainController via constructor. Tests create
instances directly — no reset seam needed.
Thanks for the review feedback, what's recently changed:
|
This PR fixes #1936
Implemented changes:
Added localization support to the JavaFX GUI — users can select a display language, and the preference is persisted across restarts.
How it works
Locale resolution — on startup,
LocalizationServiceresolves the active locale in order of priority: persisted user preference → system default → eg: English. The persisted value is stored asIDE_LOCALEin~/.ide/ide.properties.Bundle loading — resource bundles live under
src/main/resources/localization/as UTF-8.propertiesfiles (messages.propertiesfor English,messages_<tag>.propertiesfor other languages). Bundles are loaded with a customUTF8Controlto correctly handle non-ASCII characters.Locale discovery — available locales are detected dynamically at runtime by scanning the classpath for
localization/messages_*.propertiesfiles, covering both exploded directories and JARs — dropping a new bundle file withCurrentLanguageproperty is enough to make a language appear.UI integration — the language combo box is populated from the discovered locales. Each entry is labelled using the
CurrentLanguageproperty from that locale's bundle, with a fallback to a generated display name. Selecting a language applies it immediately across the UI by callingsetLocaleand persists it to~/.ide/ide.properties.Adding a new language
Add
src/main/resources/localization/messages_<tag>.propertieswith the full key set matchingmessages.properties. The language will appear in the combo box automatically on the next build.Testing instructions
AppLauncher.java— the language combo box should list all bundled languagesmessages_<tag>.propertiesfile with aCurrentLanguageproperty (ex:CurrentLanguage=French (fr)), rebuild, and launch — the new language should appear in the combo box without any code change.Checklist for this PR
Make sure everything is checked before merging this PR. For further info please also see
our DoD.
mvn clean testlocally all tests pass and build is successful#«issue-id»: «brief summary»(e.g.#921: fixed setup.bat). If no issue ID exists, title only.In Progressand assigned to you or there is no issue (might happen for very small PRs)with
internal