aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-28 15:33:11 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-28 15:33:11 +1200
commit54f802d2681537efa31b4c662a1c5846801523eb (patch)
treea623fba728daae048cd49f06df848a80b689feed /tools
parent5cfc15ffa2a5ba0ca32a9382a33288ea75fc4da5 (diff)
downloadtrackermap-server-54f802d2681537efa31b4c662a1c5846801523eb.tar.gz
trackermap-server-54f802d2681537efa31b4c662a1c5846801523eb.tar.bz2
trackermap-server-54f802d2681537efa31b4c662a1c5846801523eb.zip
Script to generate translations
Diffstat (limited to 'tools')
-rwxr-xr-xtools/translate.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/translate.py b/tools/translate.py
new file mode 100755
index 000000000..69c55979b
--- /dev/null
+++ b/tools/translate.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+import re
+import os
+
+path = '../web/l10n/'
+
+files = [f for f in os.listdir(path) if os.path.isfile(path + f) and f.endswith('.js') and not f.endswith('en.js')]
+for f in files:
+ f = path + f
+
+ dict = {}
+
+ for line in open(f).read().splitlines():
+ match = re.search(" (\\w+): '(.+)'(,)?", line)
+ if match:
+ dict[match.group(1)] = match.group(2)
+
+ out = open(f, 'w')
+
+ for line in open(path + 'en.js').read().splitlines():
+ match = re.search(" (\\w+): '(.+)'(,)?", line)
+ if match:
+ if dict.has_key(match.group(1)):
+ value = dict[match.group(1)]
+ else:
+ value = match.group(2) + ' (*)'
+
+ out.write(' ' + match.group(1) + ": '" + value + "'")
+ if match.group(3) is not None:
+ out.write(',')
+ out.write('\n')
+ else:
+ out.write(line + '\n')