This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

commit e88280bba6f2fbb5504159757a64a03b5a5424af
Author: Guillem Jover <guil...@debian.org>
Date:   Sat Feb 21 23:46:34 2015 +0100

    Dpkg::Gettext: Add support for $DEFAULT_TEXT_DOMAIN
    
    This allows to get localized messages even when the program has called
    textdomain() with a different value than the one used in the Dpkg perl
    modules. It also allows the user to set a different default domain name.
---
 debian/changelog        |  2 ++
 scripts/Dpkg/Gettext.pm | 39 ++++++++++++++++++++++++++++++++-------
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 9c54bb8..cc3bdc2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -96,6 +96,8 @@ dpkg (1.18.0) UNRELEASED; urgency=low
     slash. For the former error out, for the latter strip it. Closes: #771752
   * Support moving a conffile not being shipped anymore. Closes: #767003
     Thanks to Mathias Behrle <mathi...@m9s.biz>.
+  * Add support for $DEFAULT_TEXT_DOMAIN to Dpkg::Gettext, so that the Dpkg
+    perl modules can always produce localized messages.
 
   [ Raphaƫl Hertzog ]
   * Drop myself from Uploaders.
diff --git a/scripts/Dpkg/Gettext.pm b/scripts/Dpkg/Gettext.pm
index 9f9a81d..0b42afc 100644
--- a/scripts/Dpkg/Gettext.pm
+++ b/scripts/Dpkg/Gettext.pm
@@ -26,7 +26,7 @@ package Dpkg::Gettext;
 use strict;
 use warnings;
 
-our $VERSION = '1.01';
+our $VERSION = '1.02';
 our @EXPORT = qw(
     textdomain
     ngettext
@@ -49,19 +49,39 @@ The Dpkg::Gettext module is a convenience wrapper over the 
Locale::gettext
 module, to guarantee we always have working gettext functions, and to add
 some commonly used aliases.
 
+=head1 VARIABLES
+
+=over 4
+
+=item $Dpkg::Gettext::DEFAULT_TEXT_DOMAIN
+
+Specifies the default text domain name to be used with the short function
+aliases. This is intended to be used by the Dpkg modules, so that they
+can produce localized messages even when the calling program has set the
+current domain with textdomain(). If you would like to use the aliases
+for your own modules, you might want to set this variable to undef, or
+to another domain, but then the Dpkg modules will not produce localized
+messages.
+
+=back
+
+=cut
+
+our $DEFAULT_TEXT_DOMAIN = 'dpkg-dev';
+
 =head1 FUNCTIONS
 
 =over 4
 
 =item my $trans = g_($msgid)
 
-Calls gettext() on the $msgid and returns its translation for the current
-locale. If gettext() is not available, simply returns $msgid.
+Calls dgettext() on the $msgid and returns its translation for the current
+locale. If dgettext() is not available, simply returns $msgid.
 
 =item my $trans = P_($msgid, $msgid_plural, $n)
 
-Calls ngettext(), returning the correct translation for the plural form
-dependent on $n. If gettext() is not available, returns $msgid if $n is 1
+Calls dngettext(), returning the correct translation for the plural form
+dependent on $n. If dngettext() is not available, returns $msgid if $n is 1
 or $msgid_plural otherwise.
 
 =back
@@ -92,10 +112,10 @@ BEGIN {
     } else {
         eval q{
             sub g_ {
-                return gettext(shift);
+                return dgettext($DEFAULT_TEXT_DOMAIN, shift);
             }
             sub P_ {
-                return ngettext(@_);
+                return dngettext($DEFAULT_TEXT_DOMAIN, @_);
             }
         };
     }
@@ -114,6 +134,11 @@ sub _g ## no critic 
(Subroutines::ProhibitUnusedPrivateSubroutines)
 
 =head1 CHANGES
 
+=head2 Version 1.02
+
+Now the short aliases (g_ and P_) will call domain aware functions with
+$DEFAULT_TEXT_DOMAIN.
+
 =head2 Version 1.01
 
 New function: g_().

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/dpkg/dpkg.git


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to