diff options
author | André Apitzsch <git@apitzsch.eu> | 2017-09-19 00:48:54 +0300 |
---|---|---|
committer | André Apitzsch <git@apitzsch.eu> | 2017-09-22 20:12:26 +0300 |
commit | 3e80707eee5196b0cd0f4d22660df08e093ca0e9 (patch) | |
tree | 7596740defdf040706b9c8db8c52f8993cc35ed8 | |
parent | 864e572584e31275e9d1327982868c7ce2b26f8e (diff) |
setup.py: add update_po command
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r--[-rwxr-xr-x] | setup.py | 43 |
2 files changed, 44 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index 6ce9ba0db..37612787b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ data/org.gajim.Gajim.appdata.xml data/org.gajim.Gajim.desktop libtool po/.intltool-merge-cache +po/gajim.pot po/POTFILES po/stamp-it stamp-h1 diff --git a/setup.py b/setup.py index b61d1d38f..4d3238beb 100755..100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,35 @@ pos = [x for x in os.listdir('po') if x[-3:] == ".po"] ALL_LINGUAS = sorted([os.path.split(x)[-1][:-3] for x in pos]) cwd = os.path.dirname(os.path.realpath(__file__)) + +def update_trans(): + ''' + Update translation files + ''' + template = os.path.join('po', 'gajim.pot') + files = [os.path.join(root, f) for root, d, files in os.walk('gajim') for f in files if os.path.isfile( + os.path.join(root, f)) and (f.endswith('.py') or f.endswith('.ui'))] + files.append(os.path.join("data", "gajim-remote.desktop.in")) + files.append(os.path.join("data", "org.gajim.Gajim.desktop.in")) + files.append(os.path.join("data", "org.gajim.Gajim.appdata.xml.in")) + cmd = 'xgettext --from-code=utf-8 -o %s %s' % ( + template, " ".join(files)) + if os.system(cmd) != 0: + msg = "ERROR: %s could not be created!\n" % template + raise SystemExit(msg) + + for lang in ALL_LINGUAS: + po_file = os.path.join('po', lang + '.po') + cmd = 'msgmerge -U %s %s' % (po_file, template) + if os.system(cmd) != 0: + msg = 'ERROR: Updating language translation file failed.' + ask = msg + '\n Continue updating y/n [n] ' + reply = input(ask) + if reply in ['n', 'N']: + raise SystemExit(msg) + log.info('Updating %s', po_file) + + def build_trans(build_cmd): ''' Translate the language files into gajim.mo @@ -157,6 +186,19 @@ class test_nogui(test): def run(self): os.system("./test/runtests.py -n") +class update_po(Command): + description = "Update po files" + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + update_trans() + package_data_activities = ['data/activities/*/*/*.png'] package_data_emoticons = ['data/emoticons/*/emoticons_theme.py', @@ -209,6 +251,7 @@ setup( 'build_py': build, 'test': test, 'test_nogui': test_nogui, + 'update_po': update_po, }, scripts = [ 'scripts/gajim', |