From c05e1567e1d04e9b8678dcbaf85d5c7c84f2f315 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Wed, 12 Oct 2022 18:14:28 +0200 Subject: [PATCH] [po] added scripts to generate elinks.pot --- po/generate_pot.py | 38 ++++++++++++++++++++++++++++++++++++++ po/meson.build | 8 +++++++- po/potfiles.py | 10 ++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100755 po/generate_pot.py create mode 100755 po/potfiles.py diff --git a/po/generate_pot.py b/po/generate_pot.py new file mode 100755 index 000000000..bc8bd7927 --- /dev/null +++ b/po/generate_pot.py @@ -0,0 +1,38 @@ +#!/usr/bin/python3 + +import os +import sys + +if __name__ == '__main__': + srcdir = os.path.dirname(os.path.realpath(__file__)) + top_srcdir = os.path.abspath(os.path.join(srcdir, '..')) + potfiles = os.path.join(srcdir, 'potfiles.list') + VERSION = sys.argv[1] + os.system(f'xgettext --default-domain=elinks \ + --directory={top_srcdir} \ + --msgid-bugs-address=elinks-users@linuxfromscratch.org \ + --add-comments --language=C \ + --keyword=_ --keyword=N_ --keyword=n_:1,2 --keyword=N__ \ + --flag=msg_text:2:c-format --flag=die:1:c-format \ + --flag=secure_fprintf:2:c-format \ + --flag=DBG:1:c-format --flag=elinks_debug:1:c-format \ + --flag=WDBG:1:c-format --flag=elinks_wdebug:1:c-format \ + --flag=ERROR:1:c-format --flag=elinks_error:1:c-format \ + --flag=INTERNAL:1:c-format --flag=elinks_internal:1:c-format \ + --flag=usrerror:1:c-format --flag=elinks_log:4:c-format \ + --flag=LOG_ERR:1:c-format --flag=LOG_WARN:1:c-format \ + --flag=LOG_INFO:1:c-format --flag=LOG_DBG:1:c-format \ + --flag=assertm:2:c-format --flag=elinks_assertm:2:c-format \ + --flag=add_format_to_string:2:c-format \ + --flag=elinks_vsnprintf:3:c-format --flag=elinks_snprintf:3:c-format \ + --flag=elinks_vasprintf:2:c-format --flag=elinks_asprintf:2:c-format \ + --flag=vasprintfa:1:c-format --flag=asprintfa:1:c-format \ + --flag=_:1:pass-c-format --flag=N_:1:pass-c-format \ + --flag=n_:1:pass-c-format --flag=n_:2:pass-c-format \ + --flag=N__:1:pass-c-format \ + -f {potfiles}') + if not os.path.exists('elinks.po'): + sys.exit(1) + os.system(f'perl -I{srcdir}/perl {srcdir}/perl/msgaccel-prepare -S{top_srcdir} elinks.po') + os.system(f"sed -i -e 's/^\"Project-Id-Version: PACKAGE VERSION/\"Project-Id-Version: ELinks {VERSION}/' elinks.po") + os.system(f'mv -f elinks.po {srcdir}/elinks.pot') diff --git a/po/meson.build b/po/meson.build index 30712da1b..d2d038aa2 100644 --- a/po/meson.build +++ b/po/meson.build @@ -7,8 +7,14 @@ if conf_data.get('CONFIG_NLS') ) endif +generate_potfiles = find_program('potfiles.py') +potfiles = custom_target('generate-potfiles', command:[generate_potfiles], output:'potfiles.list') + +generate_pot = find_program('generate_pot.py') +generate_pot_tgt = custom_target('generate-pot', command:[generate_pot, meson.project_version()], depends:[potfiles], output:'elinks.pot') + check_po_sh = find_program('check_po.sh') run_target('check-po', command:[check_po_sh]) update_po_sh = find_program('update_po.sh') -run_target('update-po', command:[update_po_sh]) +run_target('update-po', command:[update_po_sh], depends:[generate_pot_tgt]) diff --git a/po/potfiles.py b/po/potfiles.py new file mode 100755 index 000000000..9ce6dc521 --- /dev/null +++ b/po/potfiles.py @@ -0,0 +1,10 @@ +#!/usr/bin/python3 + +import os + +if __name__ == '__main__': + podir = os.path.dirname(os.path.realpath(__file__)) + topsrcdir = os.path.abspath(os.path.join(podir, '..')) + potfiles = os.path.join(podir, 'potfiles.list') + os.chdir(topsrcdir) + os.system("find src/ -type f -name '*.[ch]' -o -name '*.cpp' -o -name options.inc -o -name 'actions-*.inc' | sort > %s" % potfiles)