From 6799cc87e220f04e21bf4d87561281119df10523 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 21 Nov 2011 21:52:36 +0000 Subject: Apply i18n updates from Paul Davis. git-svn-id: http://svn.drobilla.net/autowaf@60 e2e4594f-ea7b-45dc-bc5a-5f5301e603aa --- autowaf.py | 76 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/autowaf.py b/autowaf.py index c329bf1..472d6e1 100644 --- a/autowaf.py +++ b/autowaf.py @@ -424,52 +424,60 @@ def build_version_files(header_path, source_path, domain, major, minor, micro): return None -def build_i18n(bld, srcdir, dir, name, sources, copyright_holder=None): - pwd = os.getcwd() - os.chdir(os.path.join(srcdir, dir)) - +def build_i18n_pot(bld, srcdir, dir, name, sources, copyright_holder=None): + Logs.info('Generating pot file from %s' % name) pot_file = '%s.pot' % name - args = [ 'xgettext', - '--keyword=_', - '--keyword=N_', - '--from-code=UTF-8', - '-o', pot_file ] + cmd = [ 'xgettext', + '--keyword=_', + '--keyword=N_', + '--keyword=S_', + '--from-code=UTF-8', + '-o', pot_file ] if copyright_holder: - args += [ '--copyright-holder="%s"' % copyright_holder ] + cmd += [ '--copyright-holder="%s"' % copyright_holder ] - def msg(str): - sys.stdout.write(str + ' ') - sys.stdout.flush() + cmd += sources + Logs.info('Updating ' + pot_file) + subprocess.call(cmd, cwd=os.path.join(srcdir, dir)) - args += sources - msg('Updating ' + pot_file) - os.spawnvp(os.P_WAIT, 'xgettext', args) - +def build_i18n_po(bld, srcdir, dir, name, sources, copyright_holder=None): + pwd = os.getcwd() + os.chdir(os.path.join(srcdir, dir)) + pot_file = '%s.pot' % name po_files = glob.glob('po/*.po') - languages = [ po.replace('.po', '') for po in po_files ] - for po_file in po_files: - args = [ 'msgmerge', - '--update', - po_file, - pot_file ] - msg('Updating ' + po_file) - os.spawnvp(os.P_WAIT, 'msgmerge', args) - + cmd = [ 'msgmerge', + '--update', + po_file, + pot_file ] + Logs.info('Updating ' + po_file) + subprocess.call(cmd) + os.chdir(pwd) + +def build_i18n_mo(bld, srcdir, dir, name, sources, copyright_holder=None): + pwd = os.getcwd() + os.chdir(os.path.join(srcdir, dir)) + pot_file = '%s.pot' % name + po_files = glob.glob('po/*.po') for po_file in po_files: mo_file = po_file.replace('.po', '.mo') - args = [ 'msgfmt', - '-c', - '-f', - '-o', - mo_file, - po_file ] - msg('Generating ' + po_file) - os.spawnvp(os.P_WAIT, 'msgfmt', args) + cmd = [ 'msgfmt', + '-c', + '-f', + '-o', + mo_file, + po_file ] + Logs.info('Generating ' + po_file) + subprocess.call(cmd) os.chdir(pwd) +def build_i18n(bld, srcdir, dir, name, sources, copyright_holder=None): + build_i18n_pot(bld, srcdir, dir, name, sources, copyright_holder) + build_i18n_po(bld, srcdir, dir, name, sources, copyright_holder) + build_i18n_mo(bld, srcdir, dir, name, sources, copyright_holder) + def cd_to_build_dir(ctx, appname): orig_dir = os.path.abspath(os.curdir) top_level = (len(ctx.stack_path) > 1) -- cgit v1.2.1