|
|
|
@ -23,6 +23,7 @@ parser.add_argument('--pkgname', default='') |
|
|
|
|
parser.add_argument('--datadirs', default='') |
|
|
|
|
parser.add_argument('--langs', default='') |
|
|
|
|
parser.add_argument('--localedir', default='') |
|
|
|
|
parser.add_argument('--source-root', default='') |
|
|
|
|
parser.add_argument('--subdir', default='') |
|
|
|
|
parser.add_argument('--xgettext', default='xgettext') |
|
|
|
|
parser.add_argument('--msgmerge', default='msgmerge') |
|
|
|
@ -45,7 +46,7 @@ def read_linguas(src_sub: str) -> T.List[str]: |
|
|
|
|
print(f'Could not find file LINGUAS in {src_sub}') |
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
def run_potgen(src_sub: str, xgettext: str, pkgname: str, datadirs: str, args: T.List[str]) -> int: |
|
|
|
|
def run_potgen(src_sub: str, xgettext: str, pkgname: str, datadirs: str, args: T.List[str], source_root: str) -> int: |
|
|
|
|
listfile = os.path.join(src_sub, 'POTFILES.in') |
|
|
|
|
if not os.path.exists(listfile): |
|
|
|
|
listfile = os.path.join(src_sub, 'POTFILES') |
|
|
|
@ -59,7 +60,7 @@ def run_potgen(src_sub: str, xgettext: str, pkgname: str, datadirs: str, args: T |
|
|
|
|
|
|
|
|
|
ofile = os.path.join(src_sub, pkgname + '.pot') |
|
|
|
|
return subprocess.call([xgettext, '--package-name=' + pkgname, '-p', src_sub, '-f', listfile, |
|
|
|
|
'-D', os.environ['MESON_SOURCE_ROOT'], '-k_', '-o', ofile] + args, |
|
|
|
|
'-D', source_root, '-k_', '-o', ofile] + args, |
|
|
|
|
env=child_env) |
|
|
|
|
|
|
|
|
|
def update_po(src_sub: str, msgmerge: str, msginit: str, pkgname: str, langs: T.List[str]) -> int: |
|
|
|
@ -77,18 +78,16 @@ def run(args: T.List[str]) -> int: |
|
|
|
|
subcmd = options.command |
|
|
|
|
langs = options.langs.split('@@') if options.langs else None |
|
|
|
|
extra_args = options.extra_args.split('@@') if options.extra_args else [] |
|
|
|
|
subdir = os.environ.get('MESON_SUBDIR', '') |
|
|
|
|
if options.subdir: |
|
|
|
|
subdir = options.subdir |
|
|
|
|
src_sub = os.path.join(os.environ['MESON_SOURCE_ROOT'], subdir) |
|
|
|
|
subdir = options.subdir |
|
|
|
|
src_sub = os.path.join(options.source_root, subdir) |
|
|
|
|
|
|
|
|
|
if not langs: |
|
|
|
|
langs = read_linguas(src_sub) |
|
|
|
|
|
|
|
|
|
if subcmd == 'pot': |
|
|
|
|
return run_potgen(src_sub, options.xgettext, options.pkgname, options.datadirs, extra_args) |
|
|
|
|
return run_potgen(src_sub, options.xgettext, options.pkgname, options.datadirs, extra_args, options.source_root) |
|
|
|
|
elif subcmd == 'update_po': |
|
|
|
|
if run_potgen(src_sub, options.xgettext, options.pkgname, options.datadirs, extra_args) != 0: |
|
|
|
|
if run_potgen(src_sub, options.xgettext, options.pkgname, options.datadirs, extra_args, options.source_root) != 0: |
|
|
|
|
return 1 |
|
|
|
|
return update_po(src_sub, options.msgmerge, options.msginit, options.pkgname, langs) |
|
|
|
|
else: |
|
|
|
|