Merge branch 'jk/loose-object-fsck'
[gitweb.git] / perl / Git / I18N.pm
index f889fd6da91d2d9b6a7469442a02e5478f094f8d..c41425c8d07a4b9a223ef3fb71e24ff526cb9fc9 100644 (file)
@@ -13,7 +13,7 @@ BEGIN
        }
 }
 
-our @EXPORT = qw(__);
+our @EXPORT = qw(__ __n N__);
 our @EXPORT_OK = @EXPORT;
 
 sub __bootstrap_locale_messages {
@@ -44,6 +44,7 @@ BEGIN
        eval {
                __bootstrap_locale_messages();
                *__ = \&Locale::Messages::gettext;
+               *__n = \&Locale::Messages::ngettext;
                1;
        } or do {
                # Tell test.pl that we couldn't load the gettext library.
@@ -51,7 +52,10 @@ BEGIN
 
                # Just a fall-through no-op
                *__ = sub ($) { $_[0] };
+               *__n = sub ($$$) { $_[2] == 1 ? $_[0] : $_[1] };
        };
+
+       sub N__($) { return shift; }
 }
 
 1;
@@ -70,6 +74,9 @@ =head1 SYNOPSIS
 
        printf __("The following error occurred: %s\n"), $error;
 
+       printf __n("commited %d file\n", "commited %d files\n", $files), $files;
+
+
 =head1 DESCRIPTION
 
 Git's internal Perl interface to gettext via L<Locale::Messages>. If
@@ -87,6 +94,16 @@ =head2 __($)
 L<Locale::Messages>'s gettext function if all goes well, otherwise our
 passthrough fallback function.
 
+=head2 __n($$$)
+
+L<Locale::Messages>'s ngettext function or passthrough fallback function.
+
+=head2 N__($)
+
+No-operation that only returns its argument. Use this if you want xgettext to
+extract the text to the pot template but do not want to trigger retrival of the
+translation at run time.
+
 =head1 AUTHOR
 
 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avarab@gmail.com>