1gettext(3)            User Contributed Perl Documentation           gettext(3)
2
3
4

NAME

6       Locale::gettext - message handling functions
7

SYNOPSIS

9           use Locale::gettext;
10           use POSIX;     # Needed for setlocale()
11
12           setlocale(LC_MESSAGES, "");
13
14           # OO interface
15           my $d = Locale::gettext->domain("my_program");
16
17           print $d->get("Welcome to my program"), "\n";
18                   # (printed in the local language)
19
20           # Direct access to C functions
21           textdomain("my_program");
22
23           print gettext("Welcome to my program"), "\n";
24                   # (printed in the local language)
25

DESCRIPTION

27       The gettext module permits access from perl to the gettext() family of
28       functions for retrieving message strings from databases constructed to
29       internationalize software.
30
31       $d = Locale::gettext->domain(DOMAIN)
32       $d = Locale::gettext->domain_raw(DOMAIN)
33         Creates a new object for retrieving strings in the domain DOMAIN and
34         returns it. "domain" requests that strings be returned as Perl
35         strings (possibly with wide characters) if possible while
36         "domain_raw" requests that octet strings directly from functions like
37         "dgettext()".
38
39       $d->get(MSGID)
40         Calls "dgettext()" to return the translated string for the given
41         MSGID.
42
43       $d->cget(MSGID, CATEGORY)
44         Calls "dcgettext()" to return the translated string for the given
45         MSGID in the given CATEGORY.
46
47       $d->nget(MSGID, MSGID_PLURAL, N)
48         Calls "dngettext()" to return the translated string for the given
49         MSGID or MSGID_PLURAL depending on N.
50
51       $d->ncget(MSGID, MSGID_PLURAL, N, CATEGORY)
52         Calls "dngettext()" to return the translated string for the given
53         MSGID or MSGID_PLURAL depending on N in the given CATEGORY.
54
55       $d->dir([NEWDIR])
56         If NEWDIR is given, calls "bindtextdomain" to set the name of the
57         directory where messages for the domain represented by $d are found.
58         Returns the (possibly changed) current directory name.
59
60       $d->codeset([NEWCODE])
61         For instances created with "Locale::gettext->domain_raw", manuiplates
62         the character set of the returned strings.  If NEWCODE is given,
63         calls "bind_textdomain_codeset" to set the character encoding in
64         which messages for the domain represented by $d are returned. Returns
65         the (possibly changed) current encoding name.
66
67       gettext(), dgettext(), and dcgettext() attempt to retrieve a string
68       matching their "msgid" parameter within the context of the current
69       locale. dcgettext() takes the message's category and the text domain as
70       parameters while dcgettext() defaults to the LC_MESSAGES category and
71       gettext() defaults to LC_MESSAGES and uses the current text domain.  If
72       the string is not found in the database, then "msgid" is returned.
73
74       ngettext(), dngettext(), and dcngettext() function similarily but
75       implement differentiation of messages between singular and plural.  See
76       the documentation for the corresponding C functions for details.
77
78       textdomain() sets the current text domain and returns the previously
79       active domain.
80
81       bindtextdomain(domain, dirname) instructs the retrieval functions to
82       look for the databases belonging to domain "domain" in the directory
83       "dirname"
84
85       bind_textdomain_codeset(domain, codeset) instructs the retrieval
86       functions to translate the returned messages to the character encoding
87       given by codeset if the encoding of the message catalog is known.
88

NOTES

90       Not all platforms provide all of the functions. Functions that are not
91       available in the underlying C library will not be available in Perl
92       either.
93
94       Perl programs should use the object interface. In addition to being
95       able to return native Perl wide character strings,
96       "bind_textdomain_codeset" will be emulated if the C library does not
97       provide it.
98

VERSION

100       1.05.
101

SEE ALSO

103       gettext(3i), gettext(1), msgfmt(1)
104

AUTHOR

106       Phillip Vandry <vandry@TZoNE.ORG>
107
108
109
110perl v5.12.0                      2010-05-02                        gettext(3)
Impressum