static {
LinkedList<Locale> supported = new LinkedList<>();
File locales = new File("locale");
- for (File f : locales.listFiles()) {
- if ( !f.getName().endsWith(".xml")) {
- continue;
+ File[] listFiles = locales.listFiles();
+ if (listFiles != null) {
+ for (File f : listFiles) {
+ if ( !f.getName().endsWith(".xml")) {
+ continue;
+ }
+ String language = f.getName().split("\\.", 2)[0];
+ supported.add(getLocaleFromString(language));
}
- String language = f.getName().split("\\.", 2)[0];
- supported.add(getLocaleFromString(language));
}
Collections.sort(supported, new Comparator<Locale>() {
}
public String getTranslation(String text) {
+ if (text == null || text.equals("")) {
+ return text;
+ }
String string = translations.get(text);
if (string == null || string.equals("")) {
return text;
if ( !file.exists()) {
return null;
}
- Language lang = langs.get(locale.toString());
- if (lang == null) {
+ synchronized (Language.class) {
+ Language lang = langs.get(locale.toString());
+ if (lang != null) {
+ return lang;
+ }
try {
lang = new Language(locale);
langs.put(locale.toString(), lang);
} catch (SAXException e) {
e.printStackTrace();
}
+ return lang;
}
- return lang;
}
public Locale getLocale() {