[BACK]Return to gettext.3 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libintl

File: [cvs.NetBSD.org] / src / lib / libintl / gettext.3 (download)

Revision 1.12, Thu Nov 12 00:43:52 2009 UTC (14 years, 4 months ago) by joerg
Branch: MAIN
CVS Tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, netbsd-10-base, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, matt-premerge-20091211, matt-nb8-mediatek-base, matt-nb8-mediatek, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, localcount-20160914, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, cherry-xenmp-base, cherry-xenmp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver, HEAD
Changes since 1.11: +4 -4 lines

Do not use \." for comments, always use .\". Discussed with uwe@.

.\"	$NetBSD: gettext.3,v 1.12 2009/11/12 00:43:52 joerg Exp $
.\"
.\" Copyright (c) 2000 Citrus Project,
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd November 10, 2004
.Dt GETTEXT 3
.Os
.Sh NAME
.Nm gettext ,
.Nm dgettext ,
.Nm ngettext ,
.Nm dngettext ,
.Nm textdomain ,
.Nm bindtextdomain ,
.Nm bind_textdomain_codeset ,
.Nm dcgettext ,
.Nm dcngettext
.Nd message handling functions
.Sh LIBRARY
.Lb libintl
.Sh SYNOPSIS
.In libintl.h
.Ft char *
.Fn gettext "const char *msgid"
.Ft char *
.Fn dgettext "const char *domainname" "const char *msgid"
.Ft char *
.Fn ngettext "const char *msgid1" "const char *msgid2" "unsigned long int n"
.Ft char *
.Fn dngettext "const char *domainname" "const char *msgid1" "const char *msgid2" "unsigned long int n"
.Ft char *
.Fn textdomain "const char *domainname"
.Ft char *
.Fn bindtextdomain "const char *domainname" "const char *dirname"
.Ft char *
.Fn bind_textdomain_codeset "const char *domainname" "const char *codeset"
.In libintl.h
.In locale.h
.Ft char *
.Fn dcgettext "const char *domainname" "const char *msgid" "int category"
.Ft char *
.Fn dcngettext "const char *domainname" "const char *msgid1" "const char *msgid2" "unsigned long int n" "int category"
.Sh DESCRIPTION
The
.Fn gettext ,
.Fn dgettext ,
and
.Fn dcgettext
functions attempt to retrieve a
target string based on the specified
.Fa msgid
argument within the context of a
specific domain and the current locale.
The length of strings returned by
.Fn gettext ,
.Fn dgettext ,
and
.Fn dcgettext
is undetermined until the function is
called.
The
.Fa msgid
argument is a nul-terminated string.
.Pp
The
.Fn ngettext ,
.Fn dngettext ,
and
.Fn dcngettext
functions are equivalent to
.Fn gettext ,
.Fn dgettext ,
and
.Fn dcgettext ,
respectively, except for the handling of
plural forms.
The
.Fn ngettext ,
.Fn dngettext ,
and
.Fn dcngettext
functions search for the
message string using the
.Fa msgid1
argument as the key, using the argument
.Fa n
to
determine the plural form.
If no message catalogs are found,
.Fa msgid1
is returned
if
.Fa n Li == 1 ,
otherwise
.Fa msgid2
is returned.
.Pp
The
.Dv LANGUAGE
environment variable is examined first to determine the message
catalogs to be used.
The value of the
.Dv LANGUAGE
environment variable is a list
of locale names separated by colon (:) character.
If the
.Dv LANGUAGE
environment
variable is defined, each locale name is tried in the specified order and if a
message catalog containing the requested message is found, the message is
returned.
If the
.Dv LANGUAGE
environment variable is defined but failed to locate
a message catalog, the
.Fa msgid
string will be returned.
.Pp
If the
.Dv LANGUAGE
environment variable is not defined,
.Dv LC_ALL ,
.Dv LC_xxx ,
and
.Dv LANG
environment variables are examined to locate the message catalog,
following the convention used by the
.Xr setlocale 3
function.
.Pp
The pathname used to locate the message catalog is
.Pa dirname/locale/category/domainname.mo ,
where dirname is the directory specified by
.Fn bindtextdomain ,
locale is a locale name determined by the definition of environment variables,
.Fa category
is
.Dv LC_MESSAGES
if
.Fn gettext ,
.Fn ngettext ,
.Fn dgettext ,
or
.Fn dngettext
is
called, otherwise
.Dv LC_xxx
where the name is the same as the locale category name
specified by the
.Fa category
argument of
.Fn dcgettext
or
.Fn dcngettext .
.Fa domainname
is the name of the domain specified by
.Fn textdomain
or the
.Fa domainname
argument of
.Fn dgettext ,
.Fn dngettext ,
.Fn dcgettext ,
or
.Fn dcngettext .
.Pp
For
.Fn gettext
and
.Fn ngettext ,
the domain used is set by the last valid call to
.Fn textdomain .
If a valid call to
.Fn textdomain
has not been made, the default
domain (called messages) is used.
.Pp
For
.Fn dgettext ,
.Fn dngettext ,
.Fn dcgettext ,
and
.Fn dcngettext ,
the domain used is
specified by the
.Fa domainname
argument.
The
.Fa domainname
argument is equivalent in
syntax and meaning to the
.Fa domainname
argument to
.Fn textdomain ,
except that the
selection of the domain is valid only for the duration of the
.Fn dgettext ,
.Fn dngettext ,
.Fn dcgettext ,
or
.Fn dcngettext
function call.
.Pp
The
.Fn dcgettext
and
.Fn dcngettext
functions require additional argument
.Fa category
for retrieving message string for other than
.Dv LC_MESSAGES
category.
Available value for the
.Fa category
argument are
.Dv LC_CTYPE ,
.Dv LC_COLLATE ,
.Dv LC_MESSAGES ,
.Dv LC_MONETARY ,
.Dv LC_NUMERIC ,
and
.Dv LC_TIME .
The call of
.Fn dcgettext "domainname" "msgid" "LC_MESSAGES"
is equivalent to
.Fn dgettext "domainname" "msgid" .
Note that
.Dv LC_ALL
must not be used.
.Pp
The
.Fn textdomain
function sets or queries the name of the current domain of the
active
.Dv LC_MESSAGES
locale category.
The
.Fa domainname
argument is a
nul-terminated string that can contain only the characters allowed in legal
filenames.
.Pp
The
.Fa domainname
argument is the unique name of a domain on the system.
If there
are multiple versions of the same domain on one system, namespace collisions
can be avoided by using
.Fn bindtextdomain .
If
.Fn textdomain
is not called, a
default domain is selected.
The setting of domain made by the last valid call
to
.Fn textdomain
remains valid across subsequent calls to
.Xr setlocale 3 ,
and
.Fn gettext .
.Pp
The
.Fa domainname
argument is applied to the currently active LC_MESSAGES locale.
.Pp
The current setting of the domain can be queried without affecting the current
state of the domain by calling
.Fn textdomain
with
.Fa domainname
set to the
.Dv NULL
pointer.
Calling
.Fn textdomain
with a
.Fa domainname
argument of a
.Dv NULL
string sets
the domain to the default domain
.Pq messages .
.Pp
The
.Fn bindtextdomain
function binds the path predicate for a message domain
.Fa domainname
to the value contained in dirname.
If
.Fa domainname
is a non-empty
string and has not been bound previously,
.Fn bindtextdomain
binds
.Fa domainname
with
.Fa dirname .
.Pp
If
.Fa domainname
is a non-empty string and has been bound previously,
.Fn bindtextdomain
replaces the old binding with dirname.
The dirname argument
can be an absolute pathname being resolved when
.Fn gettext ,
.Fn ngettext ,
.Fn dgettext ,
.Fn dngettext ,
.Fn dcgettext ,
or
.Fn dcngettext
are called.
If
.Fa domainname
is a
.Dv NULL
pointer or an empty string,
.Fn bindtextdomain
returns a
.Dv NULL
pointer.
If
.Fn bindtextdomain
is not called, implementation-defined default directory is used.
.Pp
The
.Fn bind_textdomain_codeset
function can be used to specify the output
.Fa codeset
for message catalogs for domain
.Fa domainname .
The
.Fa codeset
argument must
be a valid codeset name which can be used for the
.Xr iconv_open 3
function.
.Pp
If the
.Fa codeset
argument is the
.Dv NULL
pointer,
.Fn bind_textdomain_codeset
returns the currently selected
.Fa codeset
for the domain with the name
.Fa domainname .
It returns a
.Dv NULL
pointer if no
.Fa codeset
has yet been selected.
.Pp
The
.Fn bind_textdomain_codeset
function can be used several times.
If used multiple times, with the same
.Fa domainname
argument,
the later call overrides the
settings made by the earlier one.
.Pp
The
.Fn bind_textdomain_codeset
function returns a pointer to a string containing
the name of the selected
.Fa codeset .
.\".Sh "RETURN VALUES"
.\".Sh EXAMPLES
.Sh SEE ALSO
.Xr setlocale 3 ,
.Xr nls 7
.\".Sh STANDARDS
.Sh HISTORY
The functions are implemented by Citrus project,
based on the documentations for GNU gettext.
.Sh BUGS
.\" The text was ripped off from Annex C of
.\" .Dq LI18NUX 2000 Globalization Specification Version 1.0 .
.\" .Pp
.Fn bind_textdomain_codeset
does not work at this moment
.Pq it always fails .