From 7871f4dc2a4bb0cc431a1c3eebd54ee93b7f5540 Mon Sep 17 00:00:00 2001 From: WiredSpast Date: Thu, 11 Aug 2022 14:35:32 +0200 Subject: [PATCH] Initial launch (no cache set) uses system language --- .../src/main/java/gearth/ui/translations/Language.java | 10 ++++++++++ .../java/gearth/ui/translations/LanguageBundle.java | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/G-Earth/src/main/java/gearth/ui/translations/Language.java b/G-Earth/src/main/java/gearth/ui/translations/Language.java index f5cf739..f2f27ab 100644 --- a/G-Earth/src/main/java/gearth/ui/translations/Language.java +++ b/G-Earth/src/main/java/gearth/ui/translations/Language.java @@ -69,4 +69,14 @@ public enum Language { .map(Language::asMenuItem) .toArray(MenuItem[]::new); } + + public static Language getSystemLanguage() { + String locale = System.getProperty("user.language"); + System.out.println(locale); + for (Language l : values()) + if (l.locale.equals(locale)) + return l; + + return ENGLISH; + } } diff --git a/G-Earth/src/main/java/gearth/ui/translations/LanguageBundle.java b/G-Earth/src/main/java/gearth/ui/translations/LanguageBundle.java index 925e788..d4002e1 100644 --- a/G-Earth/src/main/java/gearth/ui/translations/LanguageBundle.java +++ b/G-Earth/src/main/java/gearth/ui/translations/LanguageBundle.java @@ -18,7 +18,7 @@ public class LanguageBundle extends ResourceBundle { try { current = Language.valueOf((String) Cacher.get(LANGUAGE_CACHE_KEY)); } catch (Exception e) { - current = Language.ENGLISH; + current = Language.getSystemLanguage(); Cacher.put(LANGUAGE_CACHE_KEY, current.toString()); } }