Set Locale.default to selected language

e6d11fe9a3 is broken because
Locale.default is not set by HMCL at all. This commit fixes the bug.

Note that now if we want to obtain the system language, we must use
Locales.DEFAULT rather than Locale.getDefault().
This commit is contained in:
yushijinhun
2020-08-15 17:04:29 +08:00
committed by Yuhui Huang
parent 2f10948239
commit 48e2fcc601

View File

@@ -25,6 +25,8 @@ import org.jackhuang.hmcl.util.io.FileUtils;
import static org.jackhuang.hmcl.setting.ConfigHolder.config;
import java.util.Locale;
public class Settings {
private static Settings instance;
@@ -44,6 +46,9 @@ public class Settings {
}
private Settings() {
config().localizationProperty().addListener(unused -> updateSystemLocale());
updateSystemLocale();
DownloadProviders.init();
ProxyManager.init();
Accounts.init();
@@ -74,4 +79,8 @@ public class Settings {
return null;
}
}
private static void updateSystemLocale() {
Locale.setDefault(config().getLocalization().getLocale());
}
}