Skip to content

Commit 141ea98

Browse files
committed
Automatically pull system language
Only applies on first boot as the settings loader will override this value
1 parent cbeb990 commit 141ea98

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.io.File;
44
import java.io.IOException;
5+
import java.util.Locale;
6+
57
import the.bytecode.club.bytecodeviewer.bootloader.BootState;
68
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;
79
import the.bytecode.club.bytecodeviewer.gui.theme.RSTATheme;
@@ -83,7 +85,7 @@ public class Configuration
8385
public static boolean verifyCorruptedStateOnBoot = false; //eventually may be a setting
8486

8587
public static BootState bootState = BootState.START_UP;
86-
public static Language language = Language.ENGLISH;
88+
public static Language language = guessBestLanguage();
8789
public static LAFTheme lafTheme = LAFTheme.DARK;
8890
public static RSTATheme rstaTheme = lafTheme.getRSTATheme();
8991
public static long lastHotKeyExecuted = 0;
@@ -138,4 +140,17 @@ public static File getLastPluginDirectory()
138140
return new File(".");
139141
}
140142

143+
public static Language guessBestLanguage()
144+
{
145+
Locale systemLocale = Locale.getDefault();
146+
String systemLanguage = systemLocale.getLanguage();
147+
148+
Language language = Language.getLanguageCodeLookup().get(systemLanguage);
149+
150+
if(language != null)
151+
return language;
152+
153+
//fallback to english
154+
return Language.ENGLISH;
155+
}
141156
}

0 commit comments

Comments
 (0)