From 141ea98548b74ed1bf4ac6247960e462656e8515 Mon Sep 17 00:00:00 2001 From: Konloch Date: Mon, 18 Dec 2023 00:33:45 -0700 Subject: [PATCH] Automatically pull system language Only applies on first boot as the settings loader will override this value --- .../club/bytecodeviewer/Configuration.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java b/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java index 6a18338f3..ed5de0c97 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java @@ -2,6 +2,8 @@ import java.io.File; import java.io.IOException; +import java.util.Locale; + import the.bytecode.club.bytecodeviewer.bootloader.BootState; import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.gui.theme.RSTATheme; @@ -83,7 +85,7 @@ public class Configuration public static boolean verifyCorruptedStateOnBoot = false; //eventually may be a setting public static BootState bootState = BootState.START_UP; - public static Language language = Language.ENGLISH; + public static Language language = guessBestLanguage(); public static LAFTheme lafTheme = LAFTheme.DARK; public static RSTATheme rstaTheme = lafTheme.getRSTATheme(); public static long lastHotKeyExecuted = 0; @@ -138,4 +140,17 @@ public static File getLastPluginDirectory() return new File("."); } + public static Language guessBestLanguage() + { + Locale systemLocale = Locale.getDefault(); + String systemLanguage = systemLocale.getLanguage(); + + Language language = Language.getLanguageCodeLookup().get(systemLanguage); + + if(language != null) + return language; + + //fallback to english + return Language.ENGLISH; + } }