diff --git a/pkgs/development/perl-modules/Po4a/default.nix b/pkgs/development/perl-modules/Po4a/default.nix index a620f33a71c9..b6019159ecfe 100644 --- a/pkgs/development/perl-modules/Po4a/default.nix +++ b/pkgs/development/perl-modules/Po4a/default.nix @@ -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 = diff --git a/pkgs/development/perl-modules/Po4a/gettext-1.0-msginit-compat.patch b/pkgs/development/perl-modules/Po4a/gettext-1.0-msginit-compat.patch new file mode 100644 index 000000000000..86317dc9343f --- /dev/null +++ b/pkgs/development/perl-modules/Po4a/gettext-1.0-msginit-compat.patch @@ -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);