New temporary Electrum translation wiki page Wikia
[electrum-nvc.git] / mki18n.py
index 630a5bb..c8ffadd 100755 (executable)
--- a/mki18n.py
+++ b/mki18n.py
@@ -1,8 +1,10 @@
 #!/usr/bin/python
 
 import urllib2, os
+from lib.version import TRANSLATION_ID
 
-url = "https://en.bitcoin.it/wiki/Electrum/Translation?action=raw"
+#url = "https://en.bitcoin.it/w/index.php?title=Electrum/Translation&oldid=%d&action=raw"%TRANSLATION_ID
+url = "http://bitcoin.wikia.com/wiki/Electrum?oldid=%d&action=raw"%TRANSLATION_ID
 f = urllib2.urlopen(url)
 lines = f.readlines()
 dicts = {}
@@ -13,8 +15,9 @@ for line in lines:
     if not l: continue
     if l[0] != '*': continue
     if l[0:2] == '**':
-        lang, translation = l.split(':')
-        lang = lang[2:]
+        n = l.find(':')
+        translation = l[n+1:]
+        lang = l[2:n]
         if dicts.get(lang) is None: dicts[lang] = {}
         dicts[lang][message] = translation.strip()
     else:
@@ -31,7 +34,12 @@ cmd = 'xgettext -s --no-wrap -f app.fil --output=locale/messages.pot'
 print cmd
 os.system(cmd)
 
-f = open('locale/messages.pot','r')
+# Make locale directory if doesn't exist
+try:
+    os.mkdir('locale')
+except OSError:
+    pass
+f = open(os.path.join('locale', 'messages.pot'),'r')
 s = f.read()
 f.close()
 s = s.replace('CHARSET', 'utf-8')