1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[po] added scripts to generate elinks.pot

This commit is contained in:
Witold Filipczyk 2022-10-12 18:14:28 +02:00
parent 7130c42911
commit c05e1567e1
3 changed files with 55 additions and 1 deletions

38
po/generate_pot.py Executable file
View File

@ -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')

View File

@ -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])

10
po/potfiles.py Executable file
View File

@ -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)