summaryrefslogtreecommitdiff
path: root/perl/Git/I18N.pm
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-05-05 12:21:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-05-06 03:58:33 (GMT)
commit256c2dc42c812e4868532b88155f60f0a269c821 (patch)
tree06998ea8aec9590370e0ddc2503cedc43247c876 /perl/Git/I18N.pm
parent368a50d9eea16e8e1181ce12d5c3c1d50216b688 (diff)
downloadgit-256c2dc42c812e4868532b88155f60f0a269c821.zip
git-256c2dc42c812e4868532b88155f60f0a269c821.tar.gz
git-256c2dc42c812e4868532b88155f60f0a269c821.tar.bz2
perl: use mock i18n functions under NO_GETTEXT=Y
Change the logic of the i18n functions I added in 5e9637c6297 (i18n: add infrastructure for translating Git with gettext, 2011-11-18) to use pass-through functions when NO_GETTEXT is defined. This speeds up the compilation time of commands that use this library when NO_GETTEXT=Y is in effect. Loading it and POSIX.pm is around 20ms on my machine, whereas it takes 2ms to just instantiate perl itself. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'perl/Git/I18N.pm')
-rw-r--r--perl/Git/I18N.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/perl/Git/I18N.pm b/perl/Git/I18N.pm
index 2037f38..895e759 100644
--- a/perl/Git/I18N.pm
+++ b/perl/Git/I18N.pm
@@ -16,9 +16,19 @@ BEGIN {
our @EXPORT = qw(__ __n N__);
our @EXPORT_OK = @EXPORT;
+# See Git::LoadCPAN's NO_PERL_CPAN_FALLBACKS_STR for a description of
+# this "'@@' [...] '@@'" pattern.
+use constant NO_GETTEXT_STR => '@@' . 'NO_GETTEXT' . '@@';
+use constant NO_GETTEXT => (
+ q[@@NO_GETTEXT@@] ne ''
+ and
+ q[@@NO_GETTEXT@@] ne NO_GETTEXT_STR
+);
+
sub __bootstrap_locale_messages {
our $TEXTDOMAIN = 'git';
our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@@LOCALEDIR@@';
+ die "NO_GETTEXT=" . NO_GETTEXT_STR if NO_GETTEXT;
require POSIX;
POSIX->import(qw(setlocale));