mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-01 17:36:46 +01:00
Added locale to api
This commit is contained in:
parent
4d4e3a2b47
commit
db2128daeb
22
src/main/java/com/gmail/nossr50/api/LocaleAPI.java
Normal file
22
src/main/java/com/gmail/nossr50/api/LocaleAPI.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public final class LocaleAPI {
|
||||
|
||||
public static void addBundles(ResourceBundle bundle, ResourceBundle defaultBundle) {
|
||||
LocaleLoader.addResourceBundle(bundle, defaultBundle);
|
||||
}
|
||||
|
||||
public static void addBundle(ResourceBundle bundle, boolean isDefault) {
|
||||
if(isDefault) {
|
||||
addBundles(null, bundle);
|
||||
}
|
||||
else {
|
||||
addBundles(bundle, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -89,14 +89,14 @@ public final class LocaleLoader {
|
||||
|
||||
private static void initialize() {
|
||||
if (bundle == null) {
|
||||
Locale locale = getLocalFromConfig();
|
||||
Locale locale = getLocaleFromConfig();
|
||||
|
||||
bundle = ResourceBundle.getBundle(BUNDLE_ROOT, locale);
|
||||
enBundle = ResourceBundle.getBundle(BUNDLE_ROOT, Locale.US);
|
||||
}
|
||||
}
|
||||
|
||||
private static Locale getLocalFromConfig() {
|
||||
public static Locale getLocaleFromConfig() {
|
||||
Locale.setDefault(new Locale("en", "US"));
|
||||
Locale locale = null;
|
||||
String[] myLocale = Config.getInstance().getLocale().split("[-_ ]");
|
||||
@ -111,10 +111,19 @@ public final class LocaleLoader {
|
||||
}
|
||||
|
||||
public static void addResourceBundle(String bundleRoot, Locale defaultLocale) {
|
||||
Locale locale = getLocalFromConfig();
|
||||
Locale locale = getLocaleFromConfig();
|
||||
bundles.add(ResourceBundle.getBundle(bundleRoot, locale));
|
||||
defaultBundles.add(ResourceBundle.getBundle(bundleRoot, defaultLocale));
|
||||
}
|
||||
|
||||
public static void addResourceBundle(ResourceBundle bundle, ResourceBundle defaultBundle) {
|
||||
if(bundle != null) {
|
||||
bundles.add(bundle);
|
||||
}
|
||||
if(defaultBundle != null) {
|
||||
defaultBundles.add(defaultBundle);
|
||||
}
|
||||
}
|
||||
|
||||
private static String addColors(String input) {
|
||||
input = input.replaceAll("\\Q[[BLACK]]\\E", ChatColor.BLACK.toString());
|
||||
|
Loading…
Reference in New Issue
Block a user