From c58bbe4dea7f64793f0d87636295052fea39b5f4 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Thu, 2 Jun 2005 10:47:44 +0000 Subject: [PATCH] ./translations.py [help] [stats] [update] --- scripts/translations.py | 62 ++++++++++++++++++++++++++++++++++ scripts/update_translations.py | 24 ------------- 2 files changed, 62 insertions(+), 24 deletions(-) create mode 100755 scripts/translations.py delete mode 100644 scripts/update_translations.py diff --git a/scripts/translations.py b/scripts/translations.py new file mode 100755 index 000000000..1587dc584 --- /dev/null +++ b/scripts/translations.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Dedicated to Yann + +import os +import sys + +stats = False +update = False + +def visit(arg, dirname, names): + if dirname.find('.svn') != -1: + return + if dirname.endswith('LC_MESSAGES'): + if 'gajim.po' in names: + path_to_po = os.path.join(dirname, 'gajim.po') + pos = path_to_po.find('po/') + 3 #3 = len('po/') + name = path_to_po[pos:pos+2] + if update: + os.system('msgmerge -q -U ../po/'+name+'/LC_MESSAGES/gajim.po ../gajim.pot') + if stats: + print name, 'has now:' + os.system('msgfmt --statistics ' + path_to_po) + +def show_help(): + print sys.argv[0], '[help] [stats] [update]' + sys.exit(0) + +def update_pot(): + os.system('xgettext -k_ -kN_ -o gajim.pot ../src/*.py ../src/common/*.py ../src/msg.c') + +if __name__ == '__main__': + if os.path.basename(os.getcwd()) != 'scripts': + print 'run me with cwd: scripts' + sys.exit() + + path_to_dir = '../po' + + if len(sys.argv) == 2: + if sys.argv[1].startswith('h'): + show_help() + + param = sys.argv[1] + if param == 'stats': # stats only + stats = True + os.path.walk(path_to_dir, visit, None) + elif param == 'update': # update and no stats + update_pot() + update = True + os.path.walk(path_to_dir, visit, None) # update each po & no stats + print 'Done' + + elif len(sys.argv) ==1: # update & stats + update_pot() + update = True + stats = True + os.path.walk(path_to_dir, visit, None) + print 'Done' + + else: + show_help() + diff --git a/scripts/update_translations.py b/scripts/update_translations.py deleted file mode 100644 index d041d86cb..000000000 --- a/scripts/update_translations.py +++ /dev/null @@ -1,24 +0,0 @@ -import os -import sys - -def visit(arg, dirname, names): - if dirname.find('.svn') != -1: - return - if dirname.endswith('LC_MESSAGES'): - if 'gajim.po' in names: - path_to_po = os.path.join(dirname, 'gajim.po') - pos = path_to_po.find('po/') + 3 #3 = len('po/') - name = path_to_po[pos:pos+2] - os.system('msgmerge -q -U ../po/'+name+'/LC_MESSAGES/gajim.po ../gajim.pot') - print name, 'has now:' - os.system('msgfmt --statistics ' + path_to_po) - -if __name__ == '__main__': - if os.path.basename(os.getcwd()) != 'scripts': - print 'run me with cwd: scripts' - sys.exit() - - os.system('xgettext -k_ -kN_ -o gajim.pot ../src/*.py ../src/common/*.py ../src/msg.c') - path_to_dir = '../po' - - os.path.walk(path_to_dir, visit, None)