The branch, QA_3_3 has been updated via 1067a1c2eeafe398ed316f38a562b3d85e8d2230 (commit) from 3c33759072c0da83e2bd20023af6eee2dc3c9e8e (commit)
- Log ----------------------------------------------------------------- commit 1067a1c2eeafe398ed316f38a562b3d85e8d2230 Author: Michal Čihař mcihar@novell.com Date: Tue May 25 15:17:51 2010 +0200
Add script for merging back translations from gettext.
-----------------------------------------------------------------------
Summary of changes: scripts/update-from-po | 116 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 116 insertions(+), 0 deletions(-) create mode 100755 scripts/update-from-po
diff --git a/scripts/update-from-po b/scripts/update-from-po new file mode 100755 index 0000000..82dba52 --- /dev/null +++ b/scripts/update-from-po @@ -0,0 +1,116 @@ +#!/usr/bin/python + +import polib +import sys +import os +import codecs + +CODE2LANG = { + 'af': 'afrikaans', + 'ar': 'arabic', + 'az': 'azerbaijani', + 'bn': 'bangla', + 'be': 'belarusian_cyrillic', + 'be@latin': 'belarusian_latin', + 'bg': 'bulgarian', + 'bs': 'bosnian', + 'ca': 'catalan', + 'cs': 'czech', + 'da': 'danish', + 'de': 'german', + 'el': 'greek', + 'en': 'english', + 'en_GB': 'english-gb', + 'es': 'spanish', + 'et': 'estonian', + 'eu': 'basque', + 'fa': 'persian', + 'fi': 'finnish', + 'fr': 'french', + 'gl': 'galician', + 'he': 'hebrew', + 'hi': 'hindi', + 'hr': 'croatian', + 'hu': 'hungarian', + 'id': 'indonesian', + 'it': 'italian', + 'ja': 'japanese', + 'ko': 'korean', + 'ka': 'georgian', + 'lt': 'lithuanian', + 'lv': 'latvian', + 'mk': 'macedonian_cyrillic', + 'mn': 'mongolian', + 'ms': 'malay', + 'nl': 'dutch', + 'nb': 'norwegian', + 'pl': 'polish', + 'pt_BR': 'brazilian_portuguese', + 'pt': 'portuguese', + 'ro': 'romanian', + 'ru': 'russian', + 'si': 'sinhala', + 'sk': 'slovak', + 'sl': 'slovenian', + 'sq': 'albanian', + 'sr@latin': 'serbian_latin', + 'sr': 'serbian_cyrillic', + 'sv': 'swedish', + 'th': 'thai', + 'tr': 'turkish', + 'tt': 'tatarish', + 'uk': 'ukrainian', + 'zh_TW': 'chinese_traditional', + 'zh_CN': 'chinese_simplified', + 'uz': 'uzbek_cyrillic', + 'uz@latin': 'uzbek_latin', +} + +if len(sys.argv) != 2: + print 'Usage: update-from-po PATH_TO_PO_FILES' + sys.exit(1) + +pofiles = os.listdir(sys.argv[1]) + +f = file('lang/english-utf-8.inc.php', 'r') +langmap = {} +for line in f: + line = line.strip() + if line[:4] == '$str': + parts = line.split(' = ') + langmap[parts[1].strip(';').strip(''')] = parts[0].strip('$') + +for pofile in pofiles: + if pofile[-3:] != '.po': + print 'Not a po file, skipping: %s' % pofile + continue + + try: + lang = CODE2LANG[pofile[:-3]] + except KeyError: + print 'Language for %s not defined!' % pofile + + try: + langfile = codecs.open('lang/%s-utf-8.inc.php' % lang, 'r', 'utf-8').readlines() + except IOError: + print 'Language file %s does not exist!' % lang + continue + + print 'Updating %s from: %s' % (lang, pofile) + po = polib.pofile(os.path.join(sys.argv[1], pofile)) + + for translation in po.translated_entries(): + if translation.msgctxt is None: + msgid = translation.msgid.replace(''', '\'') + msgstr = translation.msgstr.replace(''', '\'') + try: + key = langmap[msgid] + keylen = len(key) + except KeyError: + continue + for i in xrange(len(langfile)): + if langfile[i][:2 + keylen] == '$%s ' % key: + langfile[i] = '$%s = '%s';\n' % (key, msgstr) + + out = file('lang/%s-utf-8.inc.php' % lang, 'w') + out.writelines([x.encode('utf-8') for x in langfile])
hooks/post-receive