perlPackages.Po4a: fix compatibility with gettext 1.0 (#502004)

This commit is contained in:
Philip Taron
2026-03-21 21:03:42 +00:00
committed by GitHub
2 changed files with 35 additions and 0 deletions
@@ -34,6 +34,14 @@ buildPerlPackage rec {
hash = "sha256-JfwyPyuje71Iw68Ov0mVJkSw5GgmH5hjPpEhmoOP58I=";
};
patches = [
# Fix compatibility with gettext >= 1.0, whose msginit merges into
# existing files instead of overwriting, producing broken PO headers
# when the output file already exists but is empty.
# https://github.com/mquinson/po4a/issues/636
./gettext-1.0-msginit-compat.patch
];
strictDeps = true;
nativeBuildInputs =
@@ -0,0 +1,27 @@
Fix po4a compatibility with gettext >= 1.0
gettext 1.0 changed msginit behavior: when the output file already
exists, msginit now merges into it (like msgmerge) instead of
overwriting. This causes problems when po4a passes an empty PO file as
the output target, because msginit produces a PO with stripped headers
and corrupted UTF-8 content.
Fix by removing the output file before calling msginit, ensuring
msginit creates a fresh PO file with proper headers.
See: https://github.com/mquinson/po4a/issues/636
See: https://savannah.gnu.org/news/?id=10853
--- a/po4a
+++ b/po4a
@@ -1875,6 +1875,10 @@
}
my $read_pot_filename = find_input_file($pot_filename);
+ # Remove the output file if it exists (e.g. as an empty file),
+ # because gettext >= 1.0's msginit merges into existing files
+ # instead of overwriting, producing broken PO headers.
+ unlink $outfile if ( -e $outfile && -z $outfile );
my $cmd =
"msginit$Config{_exe} -i \"$read_pot_filename\" --locale $lang -o \"$outfile\" --no-translator >$devnull";
run_cmd($cmd);