aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/translated_converter.py47
1 files changed, 16 insertions, 31 deletions
diff --git a/tools/translated_converter.py b/tools/translated_converter.py
index 80adf14bc..c670b6c3f 100644
--- a/tools/translated_converter.py
+++ b/tools/translated_converter.py
@@ -34,6 +34,19 @@ for o,a in opts:
if filename == '':
sys.exit('No filename given')
+def po_append(message_id, message_str, langfile):
+ # Strip ';' from msgid
+ message_id = message_id.lstrip(';')
+ if message_str == message_id:
+ message_str=''
+ message_str = message_str.replace('{ok}', '').rstrip()
+ potentry = polib.POEntry(
+ msgid = message_id.decode('utf-8'),
+ msgstr = message_str.decode('utf-8'),
+ occurrences=[(langfile,'')]
+ )
+ po.append(potentry)
+
file_mask = filename + '.*.lang'
for langfile in glob.glob(file_mask):
nofilename = langfile.replace(filename + '.','')
@@ -71,41 +84,13 @@ for langfile in glob.glob(file_mask):
# Strip '# ' from comments
message_comment = message_comment.lstrip('# ')
message_id, message_str = message_text.split('\n',1)
- # Strip ';' from msgid
- message_id = message_id.lstrip(';')
- if message_str == message_id:
- message_str=''
- potentry = polib.POEntry(
-# msgctxt = message_comment,
- msgid = message_id.decode('utf-8'),
- msgstr = message_str.decode('utf-8'),
- occurrences=[(langfile,'')]
- )
- po.append(potentry)
+ po_append(message_id, message_str, langfile)
messagetemplate='\n\n;.*?\n\n'
mpattern=re.compile(messagetemplate,re.DOTALL)
for mblock in mpattern.findall(text):
message_id, message_str = mblock.strip('\n').split('\n',1)
- # Strip ';' from msgid
- message_id = message_id.lstrip(';')
- if message_str == message_id:
- message_str=''
- potentry = polib.POEntry(
- msgid = message_id.decode('utf-8'),
- msgstr = message_str.decode('utf-8'),
- occurrences=[(langfile,'')]
- )
- po.append(potentry)
+ po_append(message_id, message_str, langfile)
if text[0] == ';':
message_id, message_str = text.partition('\n\n')[0].strip('\n').split('\n',1)
- # Strip ';' from msgid
- message_id = message_id.lstrip(';')
- if message_str == message_id:
- message_str=''
- potentry = polib.POEntry(
- msgid = message_id.decode('utf-8'),
- msgstr = message_str.decode('utf-8'),
- occurrences=[(langfile,'')]
- )
- po.append(potentry)
+ po_append(message_id, message_str, langfile)
po.save(filename + '.po')