mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06: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 {
|
public final class LocaleLoader {
|
||||||
private static final String BUNDLE_ROOT = "com.gmail.nossr50.locale.locale";
|
private static final String BUNDLE_ROOT = "com.gmail.nossr50.locale.locale";
|
||||||
private static ResourceBundle bundle = null;
|
private static ResourceBundle bundle = null;
|
||||||
|
private static ResourceBundle filesystemBundle = null;
|
||||||
private static ResourceBundle enBundle = null;
|
private static ResourceBundle enBundle = null;
|
||||||
|
|
||||||
private LocaleLoader() {};
|
private LocaleLoader() {};
|
||||||
@ -39,6 +40,13 @@ public final class LocaleLoader {
|
|||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filesystemBundle != null) {
|
||||||
|
try {
|
||||||
|
return getString(key, filesystemBundle, messageArguments);
|
||||||
|
}
|
||||||
|
catch (MissingResourceException ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return getString(key, bundle, messageArguments);
|
return getString(key, bundle, messageArguments);
|
||||||
}
|
}
|
||||||
@ -99,14 +107,12 @@ public final class LocaleLoader {
|
|||||||
Path localePath = Paths.get(mcMMO.getMainDirectory() + "locale_" + locale.toString() + ".properties");
|
Path localePath = Paths.get(mcMMO.getMainDirectory() + "locale_" + locale.toString() + ".properties");
|
||||||
if (Files.exists(localePath) && Files.isRegularFile(localePath)) {
|
if (Files.exists(localePath) && Files.isRegularFile(localePath)) {
|
||||||
try (Reader localeReader = Files.newBufferedReader(localePath)) {
|
try (Reader localeReader = Files.newBufferedReader(localePath)) {
|
||||||
bundle = new PropertyResourceBundle(localeReader);
|
filesystemBundle = new PropertyResourceBundle(localeReader);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
mcMMO.p.getLogger().log(Level.WARNING, "Failed to load locale from " + localePath, 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);
|
enBundle = ResourceBundle.getBundle(BUNDLE_ROOT, Locale.US);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user