Do not fallback to the system's default locale but to English. GitHub issue #109

auto-update
Zlatin Balevsky 2022-01-09 19:00:30 +00:00
parent 2eb3fe11e6
commit 548a981b16
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 8 additions and 2 deletions

View File

@ -31,12 +31,12 @@ public class Translator {
}
private static Locale locale = Locale.US;
private static ResourceBundle usBundle = ResourceBundle.getBundle("messages");
private static ResourceBundle usBundle = ResourceBundle.getBundle("messages", Locale.US, new Control());
private static ResourceBundle localeBundle;
public synchronized static void setLocale(String code) {
locale = Locale.forLanguageTag(code);
localeBundle = ResourceBundle.getBundle("messages", locale);
localeBundle = ResourceBundle.getBundle("messages", locale, new Control());
}
public synchronized static String trans(String key) {
@ -71,5 +71,11 @@ public class Translator {
return locale.getDisplayLanguage(locale).toUpperCase(locale);
}
}
private static class Control extends ResourceBundle.Control {
public Locale getFallbackLocale(String baseName, Locale locale) {
return null;
}
}
}