Closed GavinSmith0123 closed 6 years ago
I found that the code inside gettext_pp.pm
was being used. I found the following change fixed this issue:
--- gettext_pp-old.pm 2018-08-10 13:12:42.000000000 +0100
+++ gettext_pp.pm 2018-08-10 13:09:53.000000000 +0100
@@ -579,12 +579,11 @@
push @$domains, $domain;
}
}
+ $domains = [] unless defined $domains;
$__gettext_pp_domain_cache->{$dir}
->{$cache_key}
->{$category_name}
->{$domainname} = $domains;
-
- $domains = [] unless defined $domains;
return $domains;
}
The module should remember failed attempts to find an mo file and your fix looks reasonable.
I installed libintl-perl-1.29-1 using the
cpan
program.If there is no translation file found for a particular language (which may often be the case with English),
Locale::Messages::gettext
will makestat
calls looking for the file every time it is called, even if none were found the first time. I found this with thestrace
utility. For example, with the following Perl program astest.pl
:running
strace /usr/bin/perl test.pl
leads to output like the following being repeated infinitely:If the translation file does exist, then
stat64
is only called on the*.mo
file once or twice, e.g. withLC_MESSAGES=de_DE strace /usr/bin/perl test.pl
.This is very likely inefficient, especially for programs that call
gettext
a lot. It should be enough to try to find the file once, and give up afterwards.This does not appear to happen with glibc 2.19 with a C program such as the following:
With this program,
stat64
was not called repeatedly, regardless of the messages locale.