From 6e0ce5bbdb4467fae226849d91e6a539b5eef629 Mon Sep 17 00:00:00 2001 From: oanding Date: Thu, 23 Jul 2026 17:39:03 +0200 Subject: [PATCH 1/7] #2126 First investigation into missing options of dropdown menu. --- gui/src/main/java/com/devonfw/ide/gui/MainController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gui/src/main/java/com/devonfw/ide/gui/MainController.java b/gui/src/main/java/com/devonfw/ide/gui/MainController.java index 11e0f4399..37a056e65 100644 --- a/gui/src/main/java/com/devonfw/ide/gui/MainController.java +++ b/gui/src/main/java/com/devonfw/ide/gui/MainController.java @@ -80,11 +80,15 @@ private void initLanguageComboBox() { this.languageMap.clear(); selectedLanguage.getItems().clear(); + // This loop is iterating over de and en but only sets the key for de twice for (Locale locale : nlsService.getAvailableLocales()) { + // Maybe some file was not found and then he defaults to ROOT or something. String displayName = nlsService.getLanguageDisplayName(locale); this.languageMap.put(displayName, locale); } + var languageMap = this.languageMap.keySet(); + selectedLanguage.getItems().addAll(this.languageMap.keySet()); //initial value selectedLanguage.setValue(resolveLanguageSelection(nlsService.getLocale())); From 44dc053d182a1b1902227321a94e331c07443004 Mon Sep 17 00:00:00 2001 From: oanding Date: Mon, 27 Jul 2026 17:07:37 +0200 Subject: [PATCH 2/7] #2126 Further investigation into behaviour. --- gui/src/main/java/com/devonfw/ide/gui/MainController.java | 4 +++- gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gui/src/main/java/com/devonfw/ide/gui/MainController.java b/gui/src/main/java/com/devonfw/ide/gui/MainController.java index 37a056e65..66c715c97 100644 --- a/gui/src/main/java/com/devonfw/ide/gui/MainController.java +++ b/gui/src/main/java/com/devonfw/ide/gui/MainController.java @@ -80,8 +80,10 @@ private void initLanguageComboBox() { this.languageMap.clear(); selectedLanguage.getItems().clear(); + var availableLocales = nlsService.getAvailableLocales(); + LOG.info(availableLocales.toString()); // This loop is iterating over de and en but only sets the key for de twice - for (Locale locale : nlsService.getAvailableLocales()) { + for (Locale locale : availableLocales) { // Maybe some file was not found and then he defaults to ROOT or something. String displayName = nlsService.getLanguageDisplayName(locale); this.languageMap.put(displayName, locale); diff --git a/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java b/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java index 1378bfc74..ac518a5b4 100644 --- a/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java +++ b/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java @@ -81,6 +81,8 @@ private void initialize(Locale explicitLocale) { Locale localeToApply = explicitLocale; if (localeToApply == null) { + // Setting localeToApply to Locale.ROOT will return "" which leads to exception + // Setting localeToApply to Locale.getDefault() will return "de" based on JVM localeToApply = Locale.getDefault(); } applyLocale(localeToApply, false); @@ -240,7 +242,7 @@ private void loadBundle() { } private ResourceBundle loadBundle(Locale locale) { - + // ResourceBundle.getBundle(BUNDLE_NAME, locale) returns de bundle for en parameter... return ResourceBundle.getBundle(BUNDLE_NAME, locale); } From 4757018ab2d582df745c11627aa8e7fd9c19fd4d Mon Sep 17 00:00:00 2001 From: oanding Date: Mon, 27 Jul 2026 17:24:47 +0200 Subject: [PATCH 3/7] #2126 WIP fix for underlying problem. --- gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java b/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java index ac518a5b4..5e61af3b6 100644 --- a/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java +++ b/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java @@ -243,6 +243,9 @@ private void loadBundle() { private ResourceBundle loadBundle(Locale locale) { // ResourceBundle.getBundle(BUNDLE_NAME, locale) returns de bundle for en parameter... + if (locale.equals(Locale.ENGLISH)) { + return ResourceBundle.getBundle(BUNDLE_NAME, Locale.ROOT); + } return ResourceBundle.getBundle(BUNDLE_NAME, locale); } From 0f7e83a0851632cc13219b6e2b3dfaeaa7e527dd Mon Sep 17 00:00:00 2001 From: oanding Date: Tue, 28 Jul 2026 11:26:39 +0200 Subject: [PATCH 4/7] #2126 Added generalized solution to NlsService.java. Fixed formatting in MainController.java and extended test in NlsServiceTest.java to cover more szenarios. --- .../com/devonfw/ide/gui/MainController.java | 1 + .../com/devonfw/ide/gui/nls/NlsService.java | 15 ++++---- .../devonfw/ide/gui/nls/NlsServiceTest.java | 34 +++++++++++++------ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/gui/src/main/java/com/devonfw/ide/gui/MainController.java b/gui/src/main/java/com/devonfw/ide/gui/MainController.java index 66c715c97..06e27acab 100644 --- a/gui/src/main/java/com/devonfw/ide/gui/MainController.java +++ b/gui/src/main/java/com/devonfw/ide/gui/MainController.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; + import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.ComboBox; diff --git a/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java b/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java index 5e61af3b6..be9afc065 100644 --- a/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java +++ b/gui/src/main/java/com/devonfw/ide/gui/nls/NlsService.java @@ -68,22 +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) { - // Setting localeToApply to Locale.ROOT will return "" which leads to exception - // Setting localeToApply to Locale.getDefault() will return "de" based on JVM - 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); } @@ -242,7 +243,7 @@ private void loadBundle() { } private ResourceBundle loadBundle(Locale locale) { - // ResourceBundle.getBundle(BUNDLE_NAME, locale) returns de bundle for en parameter... + // 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); } diff --git a/gui/src/test/java/com/devonfw/ide/gui/nls/NlsServiceTest.java b/gui/src/test/java/com/devonfw/ide/gui/nls/NlsServiceTest.java index 4a59afb25..b8b97724f 100644 --- a/gui/src/test/java/com/devonfw/ide/gui/nls/NlsServiceTest.java +++ b/gui/src/test/java/com/devonfw/ide/gui/nls/NlsServiceTest.java @@ -1,6 +1,7 @@ package com.devonfw.ide.gui.nls; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.params.provider.Arguments.arguments; import java.io.IOException; import java.io.InputStream; @@ -17,11 +18,15 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; +import java.util.stream.Stream; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import com.devonfw.ide.gui.context.IdeGuiStateManager; @@ -56,16 +61,28 @@ public void tearDown() { } } - @Test - public void testGetInstanceWithLocale() { - - NlsService service = new NlsService(Locale.ENGLISH); + @ParameterizedTest + @MethodSource("localeProvider") + public void testGetInstanceWithLocale(Locale systemLocale, Locale providedLocal, Locale expectedServiceLocal, String expectedString) { + Locale.setDefault(systemLocale); + NlsService service = new NlsService(providedLocal); - assertThat(service.getLocale()).isEqualTo(Locale.ENGLISH); + assertThat(service.getLocale()).isEqualTo(expectedServiceLocal); assertThat(service.getResourceBundle()).isNotNull(); - assertThat(service.get("CurrentLanguage")).isEqualTo("English (en)"); + assertThat(service.get("CurrentLanguage")).isEqualTo(expectedString); } + static Stream localeProvider() { + return Stream.of( + arguments(Locale.GERMAN, Locale.ENGLISH, Locale.ENGLISH, "English (en)"), + arguments(Locale.GERMAN, Locale.GERMAN, Locale.GERMAN, "Deutsch (de)"), + arguments(Locale.GERMAN, null, Locale.GERMAN, "Deutsch (de)"), + arguments(Locale.ENGLISH, Locale.ENGLISH, Locale.ENGLISH, "English (en)"), + arguments(Locale.ENGLISH, Locale.GERMAN, Locale.GERMAN, "Deutsch (de)"), + arguments(Locale.ENGLISH, null, Locale.ENGLISH, "English (en)"), + arguments(Locale.FRENCH, null, Locale.ENGLISH, "English (en)") + ); + } @Test public void testSetLocale() { @@ -78,7 +95,6 @@ public void testSetLocale() { assertThat(service.get("CurrentLanguage")).isEqualTo("Deutsch (de)"); } - @Test public void testAllLocalizationBundlesContainExactlyTheEnglishKeys() throws IOException { @@ -147,7 +163,6 @@ public void testSetLocalePersistsSelectionInUserHomeIdeProperties() throws IOExc assertThat(properties.getProperty("IDE_OPTIONS")).isEqualTo("-Duser.language=de"); } - @Test public void testPersistLocaleUpdatesExistingUserLangInIdeOptions() throws IOException { @@ -314,6 +329,3 @@ private static void writeJarEntry(JarOutputStream jos, String name) throws IOExc } } - - - From 560f5e934ea10fe16338bf5e9c7c2bdcaa42b2f5 Mon Sep 17 00:00:00 2001 From: oanding Date: Tue, 28 Jul 2026 11:29:16 +0200 Subject: [PATCH 5/7] #2126 Added entry in CHANGELOG.adoc --- CHANGELOG.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 11d8fd3d6..d0ec627d5 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE Release with new features and bugfixes: +* https://github.com/devonfw/IDEasy/issues/2126[#2126]: Fix language dropdown in GUI * https://github.com/devonfw/IDEasy/issues/2176[#2176]: Support 7z archive extraction * https://github.com/devonfw/IDEasy/issues/2100[#2100]: Fix Python not available for Mac x64 From 1d1ee0896b64b495f88dd279758f4b27e1c67edb Mon Sep 17 00:00:00 2001 From: oanding Date: Tue, 28 Jul 2026 11:56:40 +0200 Subject: [PATCH 6/7] #2126 Removed investigation comments in MainController.java --- .../main/java/com/devonfw/ide/gui/MainController.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/gui/src/main/java/com/devonfw/ide/gui/MainController.java b/gui/src/main/java/com/devonfw/ide/gui/MainController.java index 06e27acab..6728992af 100644 --- a/gui/src/main/java/com/devonfw/ide/gui/MainController.java +++ b/gui/src/main/java/com/devonfw/ide/gui/MainController.java @@ -77,21 +77,14 @@ private void initialize() { } private void initLanguageComboBox() { - this.languageMap.clear(); selectedLanguage.getItems().clear(); - var availableLocales = nlsService.getAvailableLocales(); - LOG.info(availableLocales.toString()); - // This loop is iterating over de and en but only sets the key for de twice - for (Locale locale : availableLocales) { - // Maybe some file was not found and then he defaults to ROOT or something. + for (Locale locale : nlsService.getAvailableLocales()) { String displayName = nlsService.getLanguageDisplayName(locale); this.languageMap.put(displayName, locale); } - var languageMap = this.languageMap.keySet(); - selectedLanguage.getItems().addAll(this.languageMap.keySet()); //initial value selectedLanguage.setValue(resolveLanguageSelection(nlsService.getLocale())); From f33e6592de0d683778523be037e12df1a25d7ef7 Mon Sep 17 00:00:00 2001 From: oanding Date: Tue, 28 Jul 2026 13:03:07 +0200 Subject: [PATCH 7/7] #2126 Modified arguments in NlsServiceTest.java to provide actual Locale variables, which the system would return. --- .../com/devonfw/ide/gui/nls/NlsServiceTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gui/src/test/java/com/devonfw/ide/gui/nls/NlsServiceTest.java b/gui/src/test/java/com/devonfw/ide/gui/nls/NlsServiceTest.java index b8b97724f..8b4ccf562 100644 --- a/gui/src/test/java/com/devonfw/ide/gui/nls/NlsServiceTest.java +++ b/gui/src/test/java/com/devonfw/ide/gui/nls/NlsServiceTest.java @@ -74,13 +74,13 @@ public void testGetInstanceWithLocale(Locale systemLocale, Locale providedLocal, static Stream localeProvider() { return Stream.of( - arguments(Locale.GERMAN, Locale.ENGLISH, Locale.ENGLISH, "English (en)"), - arguments(Locale.GERMAN, Locale.GERMAN, Locale.GERMAN, "Deutsch (de)"), - arguments(Locale.GERMAN, null, Locale.GERMAN, "Deutsch (de)"), - arguments(Locale.ENGLISH, Locale.ENGLISH, Locale.ENGLISH, "English (en)"), - arguments(Locale.ENGLISH, Locale.GERMAN, Locale.GERMAN, "Deutsch (de)"), - arguments(Locale.ENGLISH, null, Locale.ENGLISH, "English (en)"), - arguments(Locale.FRENCH, null, Locale.ENGLISH, "English (en)") + arguments(Locale.GERMANY, Locale.ENGLISH, Locale.ENGLISH, "English (en)"), + arguments(Locale.GERMANY, Locale.GERMAN, Locale.GERMAN, "Deutsch (de)"), + arguments(Locale.GERMANY, null, Locale.GERMAN, "Deutsch (de)"), + arguments(Locale.UK, Locale.ENGLISH, Locale.ENGLISH, "English (en)"), + arguments(Locale.UK, Locale.GERMAN, Locale.GERMAN, "Deutsch (de)"), + arguments(Locale.UK, null, Locale.ENGLISH, "English (en)"), + arguments(Locale.FRANCE, null, Locale.ENGLISH, "English (en)") ); }