201 lines
6.2 KiB
HTML
201 lines
6.2 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of gettext</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>gettext</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-10-27<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Locale::gettext - message handling functions
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use Locale::gettext;
|
|
use POSIX; # Needed for setlocale()
|
|
|
|
setlocale(LC_MESSAGES, "");
|
|
|
|
# OO interface
|
|
my $d = Locale::gettext->domain("my_program");
|
|
|
|
print $d->get("Welcome to my program"), "\n";
|
|
# (printed in the local language)
|
|
|
|
# Direct access to C functions
|
|
textdomain("my_program");
|
|
|
|
print gettext("Welcome to my program"), "\n";
|
|
# (printed in the local language)
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
The gettext module permits access from perl to the <B>gettext()</B> family of
|
|
functions for retrieving message strings from databases constructed
|
|
to internationalize software.
|
|
<DL COMPACT>
|
|
<DT id="1">$d = Locale::gettext->domain(<FONT SIZE="-1">DOMAIN</FONT>)<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="2">$d = Locale::gettext->domain_raw(<FONT SIZE="-1">DOMAIN</FONT>)<DD>
|
|
|
|
|
|
|
|
|
|
|
|
Creates a new object for retrieving strings in the domain <B></B><FONT SIZE="-1"><B>DOMAIN</B></FONT><B></B>
|
|
and returns it. <TT>"domain"</TT> requests that strings be returned as
|
|
Perl strings (possibly with wide characters) if possible while
|
|
<TT>"domain_raw"</TT> requests that octet strings directly from functions
|
|
like <TT>"dgettext()"</TT>.
|
|
<DT id="3">$d->get(<FONT SIZE="-1">MSGID</FONT>)<DD>
|
|
|
|
|
|
|
|
|
|
Calls <TT>"dgettext()"</TT> to return the translated string for the given
|
|
<B></B><FONT SIZE="-1"><B>MSGID</B></FONT><B></B>.
|
|
<DT id="4">$d->cget(<FONT SIZE="-1">MSGID, CATEGORY</FONT>)<DD>
|
|
|
|
|
|
|
|
|
|
Calls <TT>"dcgettext()"</TT> to return the translated string for the given
|
|
<B></B><FONT SIZE="-1"><B>MSGID</B></FONT><B></B> in the given <B></B><FONT SIZE="-1"><B>CATEGORY</B></FONT><B></B>.
|
|
<DT id="5">$d->nget(<FONT SIZE="-1">MSGID, MSGID_PLURAL, N</FONT>)<DD>
|
|
|
|
|
|
|
|
|
|
Calls <TT>"dngettext()"</TT> to return the translated string for the given
|
|
<B></B><FONT SIZE="-1"><B>MSGID</B></FONT><B></B> or <B></B><FONT SIZE="-1"><B>MSGID_PLURAL</B></FONT><B></B> depending on <B>N</B>.
|
|
<DT id="6">$d->ncget(<FONT SIZE="-1">MSGID, MSGID_PLURAL, N, CATEGORY</FONT>)<DD>
|
|
|
|
|
|
|
|
|
|
Calls <TT>"dngettext()"</TT> to return the translated string for the given
|
|
<B></B><FONT SIZE="-1"><B>MSGID</B></FONT><B></B> or <B></B><FONT SIZE="-1"><B>MSGID_PLURAL</B></FONT><B></B> depending on <B>N</B> in the given
|
|
<B></B><FONT SIZE="-1"><B>CATEGORY</B></FONT><B></B>.
|
|
<DT id="7">$d->dir([<FONT SIZE="-1">NEWDIR</FONT>])<DD>
|
|
|
|
|
|
|
|
|
|
If <B></B><FONT SIZE="-1"><B>NEWDIR</B></FONT><B></B> is given, calls <TT>"bindtextdomain"</TT> to set the
|
|
name of the directory where messages for the domain
|
|
represented by <TT>$d</TT> are found. Returns the (possibly changed)
|
|
current directory name.
|
|
<DT id="8">$d->codeset([<FONT SIZE="-1">NEWCODE</FONT>])<DD>
|
|
|
|
|
|
|
|
|
|
For instances created with <TT>"Locale::gettext->domain_raw"</TT>, manuiplates
|
|
the character set of the returned strings.
|
|
If <B></B><FONT SIZE="-1"><B>NEWCODE</B></FONT><B></B> is given, calls <TT>"bind_textdomain_codeset"</TT> to set the
|
|
character encoding in which messages for the domain
|
|
represented by <TT>$d</TT> are returned. Returns the (possibly changed)
|
|
current encoding name.
|
|
</DL>
|
|
<P>
|
|
|
|
<B>gettext()</B>, <B>dgettext()</B>, and <B>dcgettext()</B> attempt to retrieve a string
|
|
matching their <TT>"msgid"</TT> parameter within the context of the current
|
|
locale. <B>dcgettext()</B> takes the message's category and the text domain
|
|
as parameters while <B>dgettext()</B> defaults to the <FONT SIZE="-1">LC_MESSAGES</FONT> category
|
|
and <B>gettext()</B> defaults to <FONT SIZE="-1">LC_MESSAGES</FONT> and uses the current text domain.
|
|
If the string is not found in the database, then <TT>"msgid"</TT> is returned.
|
|
<P>
|
|
|
|
<B>ngettext()</B>, <B>dngettext()</B>, and <B>dcngettext()</B> function similarily but
|
|
implement differentiation of messages between singular and plural.
|
|
See the documentation for the corresponding C functions for details.
|
|
<P>
|
|
|
|
<B>textdomain()</B> sets the current text domain and returns the previously
|
|
active domain.
|
|
<P>
|
|
|
|
<I>bindtextdomain(domain, dirname)</I> instructs the retrieval functions to look
|
|
for the databases belonging to domain <TT>"domain"</TT> in the directory
|
|
<TT>"dirname"</TT>
|
|
<P>
|
|
|
|
<I>bind_textdomain_codeset(domain, codeset)</I> instructs the retrieval
|
|
functions to translate the returned messages to the character encoding
|
|
given by <B>codeset</B> if the encoding of the message catalog is known.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
|
|
|
|
Not all platforms provide all of the functions. Functions that are
|
|
not available in the underlying C library will not be available in
|
|
Perl either.
|
|
<P>
|
|
|
|
Perl programs should use the object interface. In addition to being
|
|
able to return native Perl wide character strings,
|
|
<TT>"bind_textdomain_codeset"</TT> will be emulated if the C library does
|
|
not provide it.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>VERSION</H2>
|
|
|
|
|
|
|
|
1.07.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3i+gettext">gettext</A></B>(3i), <B><A HREF="/cgi-bin/man/man2html?1+gettext">gettext</A></B>(1), <B><A HREF="/cgi-bin/man/man2html?1+msgfmt">msgfmt</A></B>(1)
|
|
<A NAME="lbAH"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Kim Vandry <<A HREF="mailto:vandry@TZoNE.ORG">vandry@TZoNE.ORG</A>>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="9"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="10"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="11"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="12"><A HREF="#lbAE">NOTES</A><DD>
|
|
<DT id="13"><A HREF="#lbAF">VERSION</A><DD>
|
|
<DT id="14"><A HREF="#lbAG">SEE ALSO</A><DD>
|
|
<DT id="15"><A HREF="#lbAH">AUTHOR</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:47 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|