chiark / gitweb /
i18n: Source-level framework: call setlocale, provide __ and ___
[dgit.git] / Debian / Dgit / I18n.pm
1 # -*- perl -*-
2
3 package Debian::Dgit::I18n;
4
5 # This module provides
6 #    __       a function which is an alias for gettext
7 #    ___      sprintf wrapper that gettexts the format
8 #
9 # In perl the sub `_' is a `superglobal', which means there
10 # is only one of it in the whole program and every reference
11 # is to the same one.  So it's not really useable in modules.
12 # Hence __.
13
14 use Locale::gettext;
15
16 BEGIN {
17     use Exporter;
18     @ISA = qw(Exporter);
19     @EXPORT = qw(__ ___);
20 }
21
22
23 sub __ { gettext @_; }
24 sub ___ { my $f = shift @_; sprintf +(gettext $f), @_; }
25
26 1;