aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFilip Komar <filip@mageia.org>2014-03-16 12:06:53 +0000
committerFilip Komar <filip@mageia.org>2014-03-16 12:06:53 +0000
commit1c65045721c929b3e8fc82b7c4d9796fb39fb892 (patch)
tree15617371428eb0e3a00026e057c709db34f305dd /tools
parenta309d99f00031700c9de230f2eb74b0023ab0cd1 (diff)
downloadwww-1c65045721c929b3e8fc82b7c4d9796fb39fb892.tar
www-1c65045721c929b3e8fc82b7c4d9796fb39fb892.tar.gz
www-1c65045721c929b3e8fc82b7c4d9796fb39fb892.tar.bz2
www-1c65045721c929b3e8fc82b7c4d9796fb39fb892.tar.xz
www-1c65045721c929b3e8fc82b7c4d9796fb39fb892.zip
lang 2 po conversion 'translation unchanged' {ok} fix
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')