-
Notifications
You must be signed in to change notification settings - Fork 84
#2126 fix only german is listed in language selection dropdown #2221
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
Closed
oanding-blrng
wants to merge
9
commits into
devonfw:main
from
oanding-blrng:fix/2126-fix-only-german-is-listed-in-language-selection-dropdown
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6e0ce5b
#2126 First investigation into missing options of dropdown menu.
oanding-blrng bc95212
Merge branch 'main' into fix/2126-fix-only-german-is-listed-in-langua…
oanding-blrng 44dc053
#2126 Further investigation into behaviour.
oanding-blrng 4757018
#2126 WIP fix for underlying problem.
oanding-blrng 0f7e83a
#2126 Added generalized solution to NlsService.java. Fixed formatting…
oanding-blrng 7be12b4
Merge branch 'main' into fix/2126-fix-only-german-is-listed-in-langua…
oanding-blrng 560f5e9
#2126 Added entry in CHANGELOG.adoc
oanding-blrng 1d1ee08
#2126 Removed investigation comments in MainController.java
oanding-blrng f33e659
#2126 Modified arguments in NlsServiceTest.java to provide actual Loc…
oanding-blrng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,20 +68,23 @@ public class NlsService { | |
| * @param locale the preferred locale, or {@code null} to use persisted or default locale. | ||
| */ | ||
| public NlsService(Locale locale) { | ||
|
|
||
| this.availableLocales = getAvailableLocales(); | ||
| initialize(locale); | ||
| } | ||
|
|
||
| /** | ||
| * Initializes the service using an explicit, persisted, or system default locale. | ||
| * Initializes the service using an explicit, persisted, or system default locale (if applicable) or English as fallback. | ||
| * | ||
| * @param explicitLocale the locale requested by the caller, or {@code null}. | ||
| */ | ||
| private void initialize(Locale explicitLocale) { | ||
|
|
||
| Locale localeToApply = explicitLocale; | ||
| if (localeToApply == null) { | ||
| localeToApply = Locale.getDefault(); | ||
| // 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); | ||
| } | ||
|
|
@@ -240,7 +243,10 @@ private void loadBundle() { | |
| } | ||
|
|
||
| private ResourceBundle loadBundle(Locale locale) { | ||
|
|
||
| // 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); | ||
| } | ||
|
Comment on lines
+246
to
251
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same kind of error here: |
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
IMHO there is a small misunderstanding of the
Localeconcept.Internationalisation (l18n) defines a inheritance tree of:
Locale.ROOT)de,en,es, etc.)en_GBuses different spelling than American Englishen_US, you could even differentiate aspects to German for Austria inde_AT).So we can have a resource bundle with
defor German translation.However, we could also have
en_USfor 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
localeToApplyis 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
deandde_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_USwith many other languages one day via automatic translation.Uh oh!
There was an error while loading. Please reload this page.
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.
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.propertiesfile. 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.propertieswould 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 ?
Uh oh!
There was an error while loading. Please reload this page.
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.
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.