X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=i18n.py;h=a3589ff82747b9e84c54ba6a3536181d1b480b41;hp=ab7f6843bea1bfefea357b598c1c4eadbee03cc8;hb=2d4e8c5f69cc694625ad95dcee554499605f823b;hpb=3940c9ceea90f99d18792bb9ea6074ca65d7fed9 diff --git a/i18n.py b/i18n.py index ab7f6843b..a3589ff82 100644 --- a/i18n.py +++ b/i18n.py @@ -2,20 +2,29 @@ import glob import os from waflib import Logs -def pot(dir, sources, name, all = False): +def command(c): + print(c) + os.system(c) + +def pot(dir, sources, name): s = "" - for f in sources.split('\n'): + for f in sources.split(): t = f.strip() if len(t) > 0: s += (os.path.join(dir, t)) + " " - if all: - Logs.info('Making %s.pot (extracting all)' % os.path.join('build', dir, name)) - os.system('xgettext -d %s -s --extract-all -p %s -o %s.pot %s' % (name, os.path.join('build', dir), name, s)) - else: - Logs.info('Making %s.pot' % os.path.join('build', dir, name)) - os.system('xgettext -d %s -s --keyword=_ --add-comments=/ -p %s -o %s.pot %s' % (name, os.path.join('build', dir), name, s)) - + Logs.info('Making %s.pot' % os.path.join('build', dir, name)) + d = os.path.join('build', dir) + try: + os.makedirs(d) + except: + pass + + command('xgettext --from-code=UTF-8 -d %s -s --keyword=_ --keyword=S_ --add-comments=/ -p %s -o %s.pot %s' % (name, d, name, s)) + +def pot_merge(dir, name): + for f in glob.glob(os.path.join(os.getcwd(), dir, 'po', '*.po')): + command('msgmerge %s %s.pot -o %s' % (f, os.path.join('build', dir, name), f)) def po_to_mo(dir, name, bld): for f in glob.glob(os.path.join(os.getcwd(), dir, 'po', '*.po')): @@ -23,5 +32,5 @@ def po_to_mo(dir, name, bld): po = os.path.join('po', '%s.po' % lang) mo = os.path.join('mo', lang, '%s.mo' % name) - bld(rule = 'msgfmt ${SRC} -o ${TGT}', source = bld.path.make_node(po), target = bld.path.get_bld().make_node(mo)) + bld(rule='msgfmt -c ${SRC} -o ${TGT}', source=bld.path.make_node(po), target=bld.path.get_bld().make_node(mo)) bld.install_files(os.path.join('${PREFIX}', 'share', 'locale', lang, 'LC_MESSAGES'), mo)