]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/Language.java
Format code according do BenBE's formatter.
[gigi.git] / src / org / cacert / gigi / Language.java
index 75593ccf723618a47598b084611d971c987c809e..6c03b19ca59694020952ff79e3c6159eb96137e4 100644 (file)
@@ -17,61 +17,64 @@ import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
 public class Language {
-       private static HashMap<String, Language> langs = new HashMap<String, Language>();
-       HashMap<String, String> translations = new HashMap<String, String>();
-       Locale l;
 
-       private Language(String language) throws ParserConfigurationException, IOException, SAXException {
-               if (language.contains("_")) {
-                       String[] parts = language.split("_");
-                       l = new Locale(parts[0], parts[1]);
-               } else {
-                       l = new Locale(language);
-               }
+    private static HashMap<String, Language> langs = new HashMap<String, Language>();
 
-               DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-               DocumentBuilder db = dbf.newDocumentBuilder();
-               Document d = db.parse(new FileInputStream(new File("locale", language + ".xml")));
-               NodeList nl = d.getDocumentElement().getChildNodes();
-               for (int i = 0; i < nl.getLength(); i++) {
-                       if (!(nl.item(i) instanceof Element)) {
-                               continue;
-                       }
-                       Element e = (Element) nl.item(i);
-                       Element id = (Element) e.getElementsByTagName("id").item(0);
-                       Element msg = (Element) e.getElementsByTagName("msg").item(0);
-                       translations.put(id.getTextContent(), HTMLEncoder.encodeHTML(msg.getTextContent()));
-               }
-               System.out.println(translations.size() + " strings loaded.");
-       }
+    HashMap<String, String> translations = new HashMap<String, String>();
 
-       public String getTranslation(String text) {
-               String string = translations.get(text);
-               if (string == null || string.equals("")) {
-                       return text;
-               }
-               return string;
-       }
+    Locale l;
 
-       public static Language getInstance(String language) {
-               Language l = langs.get(language);
-               if (l == null) {
-                       try {
-                               l = new Language(language);
-                               langs.put(language, l);
-                       } catch (ParserConfigurationException e) {
-                               e.printStackTrace();
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                       } catch (SAXException e) {
-                               e.printStackTrace();
-                       }
-               }
-               return l;
-       }
+    private Language(String language) throws ParserConfigurationException, IOException, SAXException {
+        if (language.contains("_")) {
+            String[] parts = language.split("_");
+            l = new Locale(parts[0], parts[1]);
+        } else {
+            l = new Locale(language);
+        }
 
-       public Locale getLocale() {
-               return l;
-       }
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        Document d = db.parse(new FileInputStream(new File("locale", language + ".xml")));
+        NodeList nl = d.getDocumentElement().getChildNodes();
+        for (int i = 0; i < nl.getLength(); i++) {
+            if ( !(nl.item(i) instanceof Element)) {
+                continue;
+            }
+            Element e = (Element) nl.item(i);
+            Element id = (Element) e.getElementsByTagName("id").item(0);
+            Element msg = (Element) e.getElementsByTagName("msg").item(0);
+            translations.put(id.getTextContent(), HTMLEncoder.encodeHTML(msg.getTextContent()));
+        }
+        System.out.println(translations.size() + " strings loaded.");
+    }
+
+    public String getTranslation(String text) {
+        String string = translations.get(text);
+        if (string == null || string.equals("")) {
+            return text;
+        }
+        return string;
+    }
+
+    public static Language getInstance(String language) {
+        Language l = langs.get(language);
+        if (l == null) {
+            try {
+                l = new Language(language);
+                langs.put(language, l);
+            } catch (ParserConfigurationException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            } catch (SAXException e) {
+                e.printStackTrace();
+            }
+        }
+        return l;
+    }
+
+    public Locale getLocale() {
+        return l;
+    }
 
 }