#2126 fix only german is listed in language selection dropdown - #2221
Conversation
…ge-selection-dropdown
…matting in MainController.java and extended test in NlsServiceTest.java to cover more szenarios.
…ge-selection-dropdown
Coverage Report for CI Build 30353297832Coverage increased (+0.006%) to 72.608%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions24 previously-covered lines in 2 files lost coverage.
Coverage Stats
💛 - Coveralls |
…ual Locale variables, which the system would return.
|
I have tested on my machine, which has an English Locale, and the software starts with the right language. In addition, changing the language does indeed affect the texts in the GUI. All tests are passing too. |
hohwille
left a comment
There was a problem hiding this comment.
@oanding-blrng thanks for analysing the root of this problem. That is always the most important part of the fix. 👍
I do not agree with the fix itself. Please have a look. If there are questions remaining, please do not hesitate to ask me...
| // Locale.getDefault() returns "de_DE" (for systems set to German) which isn't the same as "de" | ||
| localeToApply = Locale.of(Locale.getDefault().getLanguage()); | ||
| if (!availableLocales.contains(localeToApply)) { | ||
| localeToApply = Locale.ENGLISH; | ||
| } | ||
| } | ||
| applyLocale(localeToApply, false); |
There was a problem hiding this comment.
IMHO there is a small misunderstanding of the Locale concept.
Internationalisation (l18n) defines a inheritance tree of:
- root (the "empty" locale as
Locale.ROOT) - the language level (e.g.
de,en,es, etc.) - country specific aspects within a language (e.g. British English as
en_GBuses different spelling than American Englishen_US, you could even differentiate aspects to German for Austria inde_AT). - there is even another level below but lets stop at this point.
So we can have a resource bundle with de for German translation.
However, we could also have en_US for American English specialities.
You might think that this does not matter since IDEasy does not do country specific differentiations. However, JavaFx does a lot of things when the locale changes.
For that we cannot simply remove such aspects here since the localeToApply is actually what is applied to JavaFx.
Therefore line 84 will sooner or later cause undesired bugs.
Great that you traced down the reason why our language dropdown was having problems because the implemented in our team was not aware of the difference between de and de_DE.
However, only consider this for the dropdown but do not change the Locale that is applied.
Some users with LTR instead of RTL writing will not like if their GUI behaves broken...
Also bear in mind that with AI translation becomes cheap.
We might introduce en_US with many other languages one day via automatic translation.
There was a problem hiding this comment.
Thank you for the explanation. After some testing (documented with a comment under the issue #2126 (comment)) on a clean branch I came up with a different solution. We could just introduce a new messages_en.properties file. This would mean, that the ResourceBundle would find the proper bundle and because of how ResourceBundle is working, he would go up the chain (in this case) to the root properties, which is containing the English localization.
messages_en.properties would be completely empty with just a comment to make additions/edits to the English localization within the root properties file.
Therefore no assumptions had to made about the structure and we don't remove certain information about the locale the user is using.
Would this be a better solution @hohwille ?
There was a problem hiding this comment.
I created a new pr #2234 with the new approach. This pr is ready for the team-review, but I wanted to wait for your opinion before kicking of the process of the team review.
If the new approach is suitable, we can close this pr and work with the new one.
| // ResourceBundle.getBundle(...) with Locale.ENGLISH would return German properties on system locale = German | ||
| if (locale.equals(Locale.ENGLISH)) { | ||
| return ResourceBundle.getBundle(BUNDLE_NAME, Locale.ROOT); | ||
| } | ||
| return ResourceBundle.getBundle(BUNDLE_NAME, locale); | ||
| } |
There was a problem hiding this comment.
Same kind of error here:
The resource bundle will do the proper inheritance automatically.
Our code shall not hard-code crazy assumptions about the current structure of our *_de.properties and *.properties vs. *_en.properties, etc.
|
This PR is replaced by PR #2234 and I therefore close it now. |
This PR fixes #2126
Implemented changes:
ResourceBundle.getBundle(...)withLocale.ENGLISHwould returnmessages_de.properties, because nomessages_en.propertiescould be found. Therefore check forLocale.ENGLISHwas added to useLocale.ROOTinstead, which would result in wantedmessages.propertiesinitialize()method inNlsService.javato convertde-DEtode, because they are NOT the same. The current behaviour is the following:Locale.getDefault()and generalize it (de-DEtodeanden-UStoen, etc.)testGetInstanceWithLocale(...)was extended to cover other machine setupsTesting instructions
Please add conscise, understandable instructions on how a reviewer can test/verify the functionality of your contribution here:
mvn test -pl gui). The the tests mentioned in the issue should run successfully againAppLauncher.java(if #1987: Fixed GUI not launching for snapshot versions #2036 is merged,./build-local-dev.shcould also be used)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