On Sat, Nov 28, 2020 at 11:10:15PM +0000, Gavin Smith wrote: > I'm trying to upgrade the bundled libintl-perl to version 1.32 for > texi2any but am hitting a problem. It's due to a fix for this bug: > > https://rt.cpan.org/Public/Bug/Display.html?id=81315 > > The result is that after upgrading the library, there are test > failures due to untranslated strings. The problem is that the > tests run under the C locale for consistent results but that > strings won't be translated if the locale is C. LC_MESSAGES or > LC_ALL need to be set for the translation. > > However, I'm not sure what to set LC_MESSAGES to, because the same > locales won't exist on all systems. The following fixes the tests > (for example "perl -w t/languages.t simple"): > > diff --git a/tp/Texinfo/Report.pm b/tp/Texinfo/Report.pm > index 19a207238..04185eeec 100644 > --- a/tp/Texinfo/Report.pm > +++ b/tp/Texinfo/Report.pm > @@ -232,6 +232,8 @@ sub _encode_i18n_string($$) > return Encode::decode($encoding, $string); > } > > +use POSIX qw(setlocale LC_MESSAGES); > + > # Get document translation - handle translations of in-document strings. > # Return a parsed Texinfo tree > sub gdt($$;$$) > @@ -244,6 +246,7 @@ sub gdt($$;$$) > my $saved_env_LC_ALL = $ENV{'LC_ALL'}; > my $saved_LANGUAGE = $ENV{'LANGUAGE'}; > > + setlocale(LC_MESSAGES, 'en_GB.utf8'); > Locale::Messages::textdomain($strings_textdomain); > > # FIXME do that only once when encoding is seen (or at beginning) > > but obviously this is not right because not everybody with have > the en_GB.utf8 locale. Changing it to en_US.utf8 still works, although > I don't think I have that locale installed (it's not listed in the output of > "locale -a"). Other attempts like fr_FR.utf8 or en_XX.utf8 lead to failure.
I still don't have a better idea other than to use a list of locales to try so that if any developer has trouble with the test suite (mainly the t/languages.t test) their locale can be added to the list.
