This class provides static methods for dealing

with THDL's internationalization issues.
This commit is contained in:
eg3p 2002-11-02 20:11:42 +00:00
parent 59d65bedc3
commit 5bfaccded7

View file

@ -0,0 +1,32 @@
package org.thdl.util;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.JComponent;
public class ThdlI18n {
private static Locale locale = null;
private static ResourceBundle resources = null;
private ThdlI18n() {}
public static ResourceBundle getResourceBundle() {
if (resources == null)
resources = ResourceBundle.getBundle("MessageBundle", getLocale());
return resources;
}
public static void setLocale(Locale l) {
Locale[] locales = Locale.getAvailableLocales();
for (int k=0; k<locales.length; k++)
if (locales[k].equals(locale)) {
JComponent.setDefaultLocale(l);
locale = l;
break;
}
}
public static Locale getLocale() {
if (locale == null)
locale = Locale.getDefault();
return locale;
}
}