mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Fall back to locale loaded from JAR when filesystem one doesn't have requested key
This commit is contained in:
parent
c2d4aeaf85
commit
0f2e1ea740
@ -19,6 +19,7 @@ import java.util.logging.Level;
|
||||
public final class LocaleLoader {
|
||||
private static final String BUNDLE_ROOT = "com.gmail.nossr50.locale.locale";
|
||||
private static ResourceBundle bundle = null;
|
||||
private static ResourceBundle filesystemBundle = null;
|
||||
private static ResourceBundle enBundle = null;
|
||||
|
||||
private LocaleLoader() {};
|
||||
@ -39,6 +40,13 @@ public final class LocaleLoader {
|
||||
initialize();
|
||||
}
|
||||
|
||||
if (filesystemBundle != null) {
|
||||
try {
|
||||
return getString(key, filesystemBundle, messageArguments);
|
||||
}
|
||||
catch (MissingResourceException ignored) {}
|
||||
}
|
||||
|
||||
try {
|
||||
return getString(key, bundle, messageArguments);
|
||||
}
|
||||
@ -99,14 +107,12 @@ public final class LocaleLoader {
|
||||
Path localePath = Paths.get(mcMMO.getMainDirectory() + "locale_" + locale.toString() + ".properties");
|
||||
if (Files.exists(localePath) && Files.isRegularFile(localePath)) {
|
||||
try (Reader localeReader = Files.newBufferedReader(localePath)) {
|
||||
bundle = new PropertyResourceBundle(localeReader);
|
||||
filesystemBundle = new PropertyResourceBundle(localeReader);
|
||||
} catch (IOException e) {
|
||||
mcMMO.p.getLogger().log(Level.WARNING, "Failed to load locale from " + localePath, e);
|
||||
bundle = ResourceBundle.getBundle(BUNDLE_ROOT, locale);
|
||||
}
|
||||
} else {
|
||||
bundle = ResourceBundle.getBundle(BUNDLE_ROOT, locale);
|
||||
}
|
||||
bundle = ResourceBundle.getBundle(BUNDLE_ROOT, locale);
|
||||
enBundle = ResourceBundle.getBundle(BUNDLE_ROOT, Locale.US);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user