X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Flocalisation%2FLanguage.java;h=4caaa79beb698533b0bb8de4f26f4aeb12945a67;hb=7243641e3fc1ded767f1070a7300a099ad98ecad;hp=4c6e39012094281c3736c5e4a73649b93c6bbe80;hpb=dc30aa8985c573b89ec42b45355f1b556290daee;p=gigi.git diff --git a/src/org/cacert/gigi/localisation/Language.java b/src/org/cacert/gigi/localisation/Language.java index 4c6e3901..4caaa79b 100644 --- a/src/org/cacert/gigi/localisation/Language.java +++ b/src/org/cacert/gigi/localisation/Language.java @@ -27,12 +27,15 @@ public class Language { static { LinkedList 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() { @@ -96,6 +99,9 @@ public class Language { } public String getTranslation(String text) { + if (text == null || text.equals("")) { + return text; + } String string = translations.get(text); if (string == null || string.equals("")) { return text; @@ -109,26 +115,23 @@ public class Language { if ( !file.exists()) { return null; } - Language lang = langs.get(locale.toString()); - if (lang == null) { - synchronized (Language.class) { - lang = langs.get(locale.toString()); - if (lang != null) { - return lang; - } - try { - lang = new Language(locale); - langs.put(locale.toString(), lang); - } catch (ParserConfigurationException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (SAXException e) { - e.printStackTrace(); - } + 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 (ParserConfigurationException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (SAXException e) { + e.printStackTrace(); } + return lang; } - return lang; } public Locale getLocale() {