145 lines
5.9 KiB
HTML
145 lines
5.9 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: C Library Functions (3)<BR>Updated: May 2001<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>
|
|
|
|
gettext, dgettext, dcgettext - translate message
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/libintl.h">libintl.h</A>></B>
|
|
|
|
<B>char * gettext (const char * </B><I>msgid</I><B>);</B>
|
|
<B>char * dgettext (const char * </B><I>domainname</I><B>, const char * </B><I>msgid</I><B>);</B>
|
|
<B>char * dcgettext (const char * </B><I>domainname</I><B>, const char * </B><I>msgid</I><B>,</B>
|
|
<B> int </B><I>category</I><B>);</B>
|
|
</PRE>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The <B>gettext</B>, <B>dgettext</B> and <B>dcgettext</B> functions attempt to
|
|
translate a text string into the user's native language, by looking up the
|
|
translation in a message catalog.
|
|
<P>
|
|
|
|
The <I>msgid</I> argument identifies the message to be translated. By
|
|
convention, it is the English version of the message, with non-ASCII
|
|
characters replaced by ASCII approximations. This choice allows the
|
|
translators to work with message catalogs, called PO files, that contain
|
|
both the English and the translated versions of each message, and can be
|
|
installed using the <B>msgfmt</B> utility.
|
|
<P>
|
|
|
|
A message domain is a set of translatable <I>msgid</I> messages. Usually,
|
|
every software package has its own message domain. The domain name is used
|
|
to determine the message catalog where the translation is looked up; it must
|
|
be a non-empty string. For the <B>gettext</B> function, it is specified through
|
|
a preceding <B>textdomain</B> call. For the <B>dgettext</B> and <B>dcgettext</B>
|
|
functions, it is passed as the <I>domainname</I> argument; if this argument is
|
|
NULL, the domain name specified through a preceding <B>textdomain</B> call is
|
|
used instead.
|
|
<P>
|
|
|
|
Translation lookup operates in the context of the current locale. For the
|
|
<B>gettext</B> and <B>dgettext</B> functions, the <B>LC_MESSAGES</B> locale
|
|
facet is used. It is determined by a preceding call to the <B>setlocale</B>
|
|
function. <B>setlocale(LC_ALL,"")</B> initializes the <B>LC_MESSAGES</B> locale
|
|
based on the first nonempty value of the three environment variables
|
|
<B>LC_ALL</B>, <B>LC_MESSAGES</B>, <B>LANG</B>; see <B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3). For the
|
|
<B>dcgettext</B> function, the locale facet is determined by the <I>category</I>
|
|
argument, which should be one of the <B>LC_xxx</B> constants defined in the
|
|
<<A HREF="file:///usr/include/locale.h">locale.h</A>> header, excluding <B>LC_ALL</B>. In both cases, the functions also
|
|
use the <B>LC_CTYPE</B> locale facet in order to convert the translated message
|
|
from the translator's codeset to the current locale's codeset, unless
|
|
overridden by a prior call to the <B>bind_textdomain_codeset</B> function.
|
|
<P>
|
|
|
|
The message catalog used by the functions is at the pathname
|
|
<I>dirname</I>/<I>locale</I>/<I>category</I>/<I>domainname</I>.mo. Here
|
|
<I>dirname</I> is the directory specified through <B>bindtextdomain</B>. Its
|
|
default is system and configuration dependent; typically it is
|
|
<I>prefix</I>/share/locale, where <I>prefix</I> is the installation prefix of the
|
|
package. <I>locale</I> is the name of the current locale facet; the GNU
|
|
implementation also tries generalizations, such as the language name without
|
|
the territory name. <I>category</I> is <B>LC_MESSAGES</B> for the <B>gettext</B>
|
|
and <B>dgettext</B> functions, or the argument passed to the <B>dcgettext</B>
|
|
function.
|
|
<P>
|
|
|
|
If the <B>LANGUAGE</B> environment variable is set to a nonempty value, and the
|
|
locale is not the "C" locale, the value of <B>LANGUAGE</B> is assumed to contain
|
|
a colon separated list of locale names. The functions will attempt to look up
|
|
a translation of <I>msgid</I> in each of the locales in turn. This is a GNU
|
|
extension.
|
|
<P>
|
|
|
|
In the "C" locale, or if none of the used catalogs contain a translation for
|
|
<I>msgid</I>, the <B>gettext</B>, <B>dgettext</B> and <B>dcgettext</B> functions
|
|
return <I>msgid</I>.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
If a translation was found in one of the specified catalogs, it is converted
|
|
to the locale's codeset and returned. The resulting string is statically
|
|
allocated and must not be modified or freed. Otherwise <I>msgid</I> is returned.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<B>errno</B> is not modified.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
The return type ought to be <B>const char *</B>, but is <B>char *</B> to avoid
|
|
warnings in C code predating ANSI C.
|
|
<P>
|
|
|
|
When an empty string is used for <I>msgid</I>, the functions may return a
|
|
nonempty string.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+ngettext">ngettext</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+dngettext">dngettext</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+dcngettext">dcngettext</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+textdomain">textdomain</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+bindtextdomain">bindtextdomain</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+bind_textdomain_codeset">bind_textdomain_codeset</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+msgfmt">msgfmt</A></B>(1)
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">BUGS</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">SEE ALSO</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:44 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|