4 use warnings
$ENV{GIT_PERL_FATAL_WARNINGS
} ?
qw(FATAL all) : ();
8 *import
= \
&Exporter
::import
;
10 # Exporter 5.57 which supports this invocation was
11 # released with perl 5.8.3
12 Exporter
->import('import');
16 our @EXPORT = qw(__ __n N__);
17 our @EXPORT_OK = @EXPORT;
19 # See Git::LoadCPAN's NO_PERL_CPAN_FALLBACKS_STR for a description of
20 # this "'@@' [...] '@@'" pattern.
21 use constant NO_GETTEXT_STR
=> '@@' . 'NO_GETTEXT' . '@@';
22 use constant NO_GETTEXT
=> (
23 q
[@
@NO_GETTEXT@@
] ne ''
25 q
[@
@NO_GETTEXT@@
] ne NO_GETTEXT_STR
28 sub __bootstrap_locale_messages
{
29 our $TEXTDOMAIN = 'git';
30 our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR
} || '@@LOCALEDIR@@';
31 die "NO_GETTEXT=" . NO_GETTEXT_STR
if NO_GETTEXT
;
34 POSIX
->import(qw(setlocale));
35 # Non-core prerequisite module
36 require Locale
::Messages
;
37 Locale
::Messages
->import(qw(:locale_h :libintl_h));
39 setlocale
(LC_MESSAGES
(), '');
40 setlocale
(LC_CTYPE
(), '');
41 textdomain
($TEXTDOMAIN);
42 bindtextdomain
($TEXTDOMAIN => $TEXTDOMAINDIR);
49 # Used by our test script to see if it should test fallbacks or
51 our $__HAS_LIBRARY = 1;
55 __bootstrap_locale_messages
();
56 *__
= \
&Locale
::Messages
::gettext
;
57 *__n
= \
&Locale
::Messages
::ngettext
;
60 # Tell test.pl that we couldn't load the gettext library.
61 $Git::I18N
::__HAS_LIBRARY
= 0;
63 # Just a fall-through no-op
64 *__
= sub ($) { $_[0] };
65 *__n
= sub ($$$) { $_[2] == 1 ?
$_[0] : $_[1] };
68 sub N__
($) { return shift; }
77 Git::I18N - Perl interface to Git's Gettext localizations
83 print __("Welcome to Git!\n");
85 printf __("The following error occurred: %s\n"), $error;
87 printf __n("committed %d file\n", "committed %d files\n", $files), $files;
92 Git's internal Perl interface to gettext via L<Locale::Messages>. If
93 L<Locale::Messages> can't be loaded (it's not a core module) we
94 provide stub passthrough fallbacks.
96 This is a distilled interface to gettext, see C<info '(gettext)Perl'>
97 for the full interface. This module implements only a small part of
104 L<Locale::Messages>'s gettext function if all goes well, otherwise our
105 passthrough fallback function.
109 L<Locale::Messages>'s ngettext function or passthrough fallback function.
113 No-operation that only returns its argument. Use this if you want xgettext to
114 extract the text to the pot template but do not want to trigger retrival of the
115 translation at run time.
119 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avarab@gmail.com>
123 Copyright 2010 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avarab@gmail.com>