summaryrefslogtreecommitdiffstats
path: root/kgeography/src/script.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 (patch)
treed3bb9f5d25a2dc09ca81adecf39621d871534297 /kgeography/src/script.cpp
downloadtdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.tar.gz
tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kgeography/src/script.cpp')
-rw-r--r--kgeography/src/script.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/kgeography/src/script.cpp b/kgeography/src/script.cpp
new file mode 100644
index 00000000..b23d31d0
--- /dev/null
+++ b/kgeography/src/script.cpp
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Albert Astals Cid *
+ * tsdgeos@terra.es *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#include <stdio.h>
+
+#include <qdir.h>
+#include <qdom.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+int main(int argc, char *argv[])
+{
+ if (argc != 3)
+ {
+ qDebug("Usage: ./script dirWithkgmFiles fileToOutputTranslations");
+ return 1;
+ }
+
+ QDir d(argv[1], "*.kgm");
+ if (!d.exists()) return 2;
+
+ QFile *output = new QFile(argv[2]);
+ output->open(IO_WriteOnly | IO_Truncate);
+ QTextStream os(output);
+ os.setEncoding(QTextStream::UnicodeUTF8);
+
+ QStringList files = d.entryList();
+ QStringList::const_iterator it;
+ QDomDocument dd;
+
+ for (it = files.begin(); it != files.end(); ++it)
+ {
+ QFile *f = new QFile(d.absPath() + "/" + *it);
+ f -> open(IO_ReadOnly);
+ dd.setContent(f);
+
+ QDomNode n, n2, n3, n4, n5;
+ QDomNodeList nodes = dd.firstChild().childNodes();
+ for (uint i = 0; i < nodes.count(); i++)
+ {
+ n = nodes.item(i);
+ if (n.nodeName() == "name")
+ {
+ os << "i18n(\"" << *it << "\", \"" << n.firstChild().nodeValue() << "\");\n";
+ os << "i18n(\"" << *it << "\", \"<qt>Current map:<br><b>" << n.firstChild().nodeValue() << "</b></qt>\");\n";
+ }
+ else if (n.nodeName() == "division")
+ {
+ n2 = n.namedItem("name");
+ os << "i18n(\"" << *it << "\", \"" << n2.firstChild().nodeValue() << "\");\n";
+
+ n3 = n.namedItem("ignore");
+ if (n3.isNull() || (n3.firstChild().nodeValue() != "yes" && n3.firstChild().nodeValue() != "allowClickMode"))
+ {
+ os << "i18n(\"" << *it << "\", \"The capital of " << n2.firstChild().nodeValue() << " is...\");\n";
+ os << "i18n(\"" << *it << "\", \"Please click on:\\n" << n2.firstChild().nodeValue() << "\");\n";
+
+ n4 = n.namedItem("flag");
+ if (!n4.isNull())
+ {
+ os << "i18n(\"" << *it << "\", \"The flag of " << n2.firstChild().nodeValue() << " is...\");\n";
+ }
+
+ n5 = n.namedItem("capital");
+ os << "i18n(\"" << *it << "\", \"" << n5.firstChild().nodeValue() << "\");\n";
+ os << "i18n(\"" << *it << "\", \"" << n5.firstChild().nodeValue() << " is the capital of...\");\n";
+ }
+ else if (n3.firstChild().nodeValue() == "allowClickMode")
+ {
+ os << "i18n(\"" << *it << "\", \"Please click on:\\n" << n2.firstChild().nodeValue() << "\");\n";
+ }
+ }
+ }
+
+ f -> close();
+ delete f;
+ }
+ output->close();
+}