Initial launch (no cache set) uses system language

This commit is contained in:
WiredSpast 2022-08-11 14:35:32 +02:00
parent 7a456bd1f3
commit 7871f4dc2a
2 changed files with 11 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -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());
}
}