This class provides static methods for dealing
with THDL's internationalization issues.
This commit is contained in:
parent
59d65bedc3
commit
5bfaccded7
1 changed files with 32 additions and 0 deletions
32
source/org/thdl/util/ThdlI18n.java
Normal file
32
source/org/thdl/util/ThdlI18n.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue