- 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;
- while ((s = readLine(sc)) != null) {
- if (!s.startsWith("\"")) {
- break;
- }
- contents.append(s.substring(1, s.length() - 1));
- }
- return s;
- }
+ DOMSource source = new DOMSource(doc);
+ 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.transform(source, result);
+ fos.close();
+ }
+ System.out.println("Done.");
+ }
+
+ private static String readLine(Scanner sc) {
+ String line = sc.findWithinHorizon("[^\n]*\n", 0);
+ if (line == null) {
+ return null;
+ }
+ 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);
+ Element tr = doc.createElement("translation");
+ Element e = doc.createElement("id");
+ e.appendChild(idN);
+ tr.appendChild(e);
+ e = doc.createElement("msg");
+ e.appendChild(textN);
+ tr.appendChild(e);
+ doc.getDocumentElement().appendChild(tr);
+ }
+
+ 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;
+ while ((s = readLine(sc)) != null) {
+ if ( !s.startsWith("\"")) {
+ break;
+ }
+ contents.append(s.substring(1, s.length() - 1));
+ }
+ return s;
+ }