mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-20 18:44:19 +00:00
cleanup
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1388 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
a314f16f90
commit
e18cd69b5d
1 changed files with 20 additions and 15 deletions
|
@ -1,10 +1,8 @@
|
||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
@ -282,7 +280,9 @@ public class Util
|
||||||
return Math.round(d * 100.0) / 100.0;
|
return Math.round(d * 100.0) / 100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConfigClassLoader extends ClassLoader {
|
|
||||||
|
private static class ConfigClassLoader extends ClassLoader
|
||||||
|
{
|
||||||
private File dataFolder;
|
private File dataFolder;
|
||||||
private ClassLoader cl;
|
private ClassLoader cl;
|
||||||
|
|
||||||
|
@ -364,29 +364,34 @@ public class Util
|
||||||
cl.setPackageAssertionStatus(string, bln);
|
cl.setPackageAssertionStatus(string, bln);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Locale defaultLocale = Locale.getDefault();
|
private static final Locale defaultLocale = Locale.getDefault();
|
||||||
public static Locale currentLocale = defaultLocale;
|
public static Locale currentLocale = defaultLocale;
|
||||||
private static ResourceBundle bundle = ResourceBundle.getBundle("messages", defaultLocale);
|
private static ResourceBundle bundle = ResourceBundle.getBundle("messages", defaultLocale);
|
||||||
|
|
||||||
public static String i18n(String string) {
|
public static String i18n(String string)
|
||||||
|
{
|
||||||
return bundle.getString(string);
|
return bundle.getString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String format(String string, Object... objects) {
|
public static String format(String string, Object... objects)
|
||||||
|
{
|
||||||
MessageFormat mf = new MessageFormat(i18n(string));
|
MessageFormat mf = new MessageFormat(i18n(string));
|
||||||
return mf.format(objects);
|
return mf.format(objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateLocale(String loc, File dataFolder) {
|
public static void updateLocale(String loc, File dataFolder)
|
||||||
if (loc == null || loc.isEmpty()) {
|
{
|
||||||
|
if (loc == null || loc.isEmpty())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String[] parts = loc.split("_");
|
String[] parts = loc.split("_");
|
||||||
if (parts.length == 1) {
|
if (parts.length == 1)
|
||||||
|
{
|
||||||
currentLocale = new Locale(parts[0]);
|
currentLocale = new Locale(parts[0]);
|
||||||
}
|
}
|
||||||
if (parts.length == 2) {
|
if (parts.length == 2)
|
||||||
|
{
|
||||||
currentLocale = new Locale(parts[0], parts[1]);
|
currentLocale = new Locale(parts[0], parts[1]);
|
||||||
}
|
}
|
||||||
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(dataFolder, Util.class.getClassLoader()));
|
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(dataFolder, Util.class.getClassLoader()));
|
||||||
|
|
Loading…
Reference in a new issue