X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=util%2Forg%2Fcacert%2Fgigi%2Futil%2FFetchLocales.java;fp=util%2Forg%2Fcacert%2Fgigi%2Futil%2FFetchLocales.java;h=731ba7c8ff074ed3d642b8d4d327d74cbe3f8a34;hb=2824d1c165c501e2f3a8809044788b33b81f478a;hp=c5378438623f217e29b7c5d365fb1736ed601121;hpb=8ef6a07673d3f52d9cb72b20f2560f12a6727459;p=gigi.git diff --git a/util/org/cacert/gigi/util/FetchLocales.java b/util/org/cacert/gigi/util/FetchLocales.java index c5378438..731ba7c8 100644 --- a/util/org/cacert/gigi/util/FetchLocales.java +++ b/util/org/cacert/gigi/util/FetchLocales.java @@ -23,13 +23,11 @@ import org.w3c.dom.Node; public class FetchLocales { public static final String DOWNLOAD_SERVER = "translations.cacert.org"; - public static final String PO_URL_TEMPLATE = "http://" + DOWNLOAD_SERVER - + "/export/cacert/%/messages.po"; - public static final String[] AUTO_LANGS = new String[]{"en", "de", "nl", - "pt_BR", "fr", "sv", "it", "es", "hu", "fi", "ja", "bg", "pt", - "da", "pl", "zh_CN", "ru", "lv", "cs", "zh_TW", "el", "tr", "ar"}; - public static void main(String[] args) throws IOException, - ParserConfigurationException, TransformerException { + public static final String PO_URL_TEMPLATE = "http://" + DOWNLOAD_SERVER + "/export/cacert/%/messages.po"; + public static final String[] AUTO_LANGS = new String[] { "en", "de", "nl", "pt_BR", "fr", "sv", "it", "es", "hu", + "fi", "ja", "bg", "pt", "da", "pl", "zh_CN", "ru", "lv", "cs", "zh_TW", "el", "tr", "ar" }; + + public static void main(String[] args) throws IOException, ParserConfigurationException, TransformerException { System.out.println("downloading locales ..."); File locale = new File("locale"); locale.mkdir(); @@ -55,8 +53,7 @@ public class FetchLocales { contents.delete(0, contents.length()); // System.out.println("msgstr"); s = readString(s, sc, contents); - String msg = contents.toString().replace("\\\"", "\"") - .replace("\\n", "\n"); + String msg = contents.toString().replace("\\\"", "\"").replace("\\n", "\n"); insertTranslation(doc, id, msg); } else if (s.startsWith("#")) { // System.out.println(s); @@ -71,16 +68,15 @@ public class FetchLocales { Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(doc); - FileOutputStream fos = new FileOutputStream(new File(locale, lang - + ".xml")); + FileOutputStream fos = new FileOutputStream(new File(locale, lang + ".xml")); StreamResult result = new StreamResult(fos); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty( - "{http://xml.apache.org/xslt}indent-amount", "2"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); transformer.transform(source, result); fos.close(); } } + private static String readLine(Scanner sc) { String line = sc.findWithinHorizon("[^\n]*\n", 0); if (line == null) { @@ -88,6 +84,7 @@ public class FetchLocales { } return line.substring(0, line.length() - 1); } + private static void insertTranslation(Document doc, String id, String msg) { Node idN = doc.createTextNode(id); Node textN = doc.createTextNode(msg); @@ -100,8 +97,8 @@ public class FetchLocales { tr.appendChild(e); doc.getDocumentElement().appendChild(tr); } - private static String readString(String head, Scanner sc, - StringBuffer contents) throws IOException { + + private static String readString(String head, Scanner sc, StringBuffer contents) throws IOException { head = head.split(" ", 2)[1]; contents.append(head.substring(1, head.length() - 1)); String s;