File: I18n.pm

package info (click to toggle)
dgit 13.20
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,084 kB
  • sloc: perl: 13,961; sh: 7,268; makefile: 340; python: 334; tcl: 69
file content (28 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -*- perl -*-

package Debian::Dgit::I18n;

# This module provides
#    __       a function which is an alias for gettext
#    f_       sprintf wrapper that gettexts the format
#    i_       identify function, but marks string for translation
#
# In perl the sub `_' is a `superglobal', which means there
# is only one of it in the whole program and every reference
# is to the same one.  So it's not really usable in modules.
# Hence __.

use Locale::gettext;

BEGIN {
    use Exporter;
    @ISA = qw(Exporter);
    @EXPORT = qw(__ f_ i_);
}


sub __ ($) { gettext @_; }
sub i_ ($) { $_[0]; }
sub f_ ($$;@) { my $f = shift @_; sprintf +(gettext $f), @_; }

1;