In the Texinfo project, I was updating the version number and regenerating translations. We are now using the translations for Gnulib code that are updated automatically when gnulib-tool runs.
However, I found that the version number in the translation files in one of the Gnulib imports was not being updated. I had updated the project version to 7.1.92 but the header in our file (tp/Texinfo/XS/gnulib/po/texinfo_tp-gnulib.pot ) remained as "Project-Id-Version: GNU texinfo 7.1.91\n" Digging into the commands run by the Makefile to update this, I found that the file was supposed to be updated by "make texinfo_tp-gnulib.pot-update". This ran xgettext which is one of the gettext programs to handle message files: /usr/local/bin/xgettext --default-domain=texinfo_tp-gnulib --directory=../.. \ --add-comments=TRANSLATORS: \ --files-from=./POTFILES.in \ --copyright-holder='Free Software Foundation, Inc.' \ --msgid-bugs-address="$msgid_bugs_address" \ --keyword=_ --flag=_:1:pass-c-format --keyword=N_ --flag=N_:1:pass-c-format --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' --keyword='proper_name_lite:1,"This is a proper name. See the gettext manual, section Names."' --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' --flag=error:3:c-format --flag=error_at_line:5:c-format --flag=asprintf:2:c-format --flag=vasprintf:2:c-format However, I found that this was not producing any output file (supposed to be "texinfo_tp-gnulib.po"). I found that the reason for this was that there were not actually any translatable strings discovered in the files listed in POTFILES.in. There had been translatable strings in the past, before Gnulib module removals. This is likely to happen for other project too if they do not use many Gnulib modules or remove modules. The effect of this means that the package will be distributed with the Gnulib translation catalogs with extra translations in them that the program does not use. I found that xgettext needs the --force-po option to output an empty file (which then becomes a .pot file with Makefile rules). Hence, I suggest the following change to use this option for Gnulib's runs of xgettext: diff --git a/ChangeLog b/ChangeLog index c70df89b2f..11ab674fae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2023-12-06 Gavin Smith <gavinsmith0...@gmail.com> + + gnulib-tool: use xgettext --force-po + * pygnulib/GLEmiter.py (po_Makevars): Put --force-po in + XGETTEXT_OPTIONS. + * gnulib-tool.sh (XGETTEXT_OPTIONS): Likewise. + + This means that empty .pot files will be generated if all + translatable strings are removed, for example with the removal + of modules. + 2024-10-17 Sam Russell <sam.h.russ...@gmail.com> crc: New tests for non-byte-aligned data. diff --git a/gnulib-tool.sh b/gnulib-tool.sh index d4f8792898..244f17b472 100755 --- a/gnulib-tool.sh +++ b/gnulib-tool.sh @@ -4091,6 +4091,7 @@ func_emit_po_Makevars () cat <<\EOF # These options get passed to xgettext. XGETTEXT_OPTIONS = \ + --force-po \ --keyword=_ --flag=_:1:pass-c-format \ --keyword=N_ --flag=N_:1:pass-c-format \ --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \ diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index 7eb8b27d46..4638be3789 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -425,6 +425,7 @@ def po_Makevars(self) -> str: emit += ''' # These options get passed to xgettext. XGETTEXT_OPTIONS = \\ + --force-po \\ --keyword=_ --flag=_:1:pass-c-format \\ --keyword=N_ --flag=N_:1:pass-c-format \\ --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \\