Previous section To contents Next section

14.15 Locale.Gettext

DESCRIPTION
This module enables access to localization functions from within Pike.

NOTE
$Id: gettext.c,v 1.5 2000/08/10 09:51:52 per Exp $

METHOD
Locale.Gettext.bindtextdomain

SYNTAX
string bindtextdomain(string|void domainname,  string|void dirname)

DESCRIPTION
The bindtextdomain() function binds the path predicate for a message domain domainname to the value contained in dirname. If domainname is a non-empty string and has not been bound previously, bindtextdomain() binds domainname with dirname.

If domainname is a non-empty string and has been bound previously, bindtextdomain() replaces the old binding with dirname. The dirname argument can be an absolute or relative pathname being resolved when gettext(), dgettext(), or dcgettext() are called. If domainname is null pointer or an empty string, bindtextdomain() returns 0. User defined domain names cannot begin with the string SYS_. Domain names beginning with this string are reserved for system use. The return value from bindtextdomain() is a string containing dirname or the directory binding associated with domainname if dirname is void. If no binding is found, the default locale path is returned. If domainname is void or an empty string, bindtextdomain() takes no action and returns a 0.

ARGUMENTS
argument(s)description
string domainname
The domain to query or bind a path to.
string dirname
The directory name to bind to the choosen domain.

SEE ALSO
textdomain, gettext, dgettext, dcgettext, setlocale and localeconv

METHOD
Locale.Gettext.dcgettext

SYNTAX
string dcgettext(string domain,  string msg,  int category)

DESCRIPTION
Return a translated version of msg within the context of the specified domain and current locale for the specified category. Calling dcgettext with category Locale.Gettext.LC_MESSAGES gives the same result as dgettext. If there is not translation available, msg is returned.

ARGUMENTS
argument(s)description
string domain
The domain to lookup the message in.
string msg
The message to translate.
int category
The category which locale should be used.

SEE ALSO
bindtextdomain, textdomain, gettext, dgettext, setlocale and localeconv

METHOD
Locale.Gettext.dgettext

SYNTAX
string dgettext(string domain,  string msg)

DESCRIPTION
Return a translated version of msg within the context of the specified domain and current locale. If there is not translation available, msg is returned.

ARGUMENTS
argument(s)description
string domain
The domain to lookup the message in.
string msg
The message to translate.

SEE ALSO
bindtextdomain, textdomain, gettext, dcgettext, setlocale and localeconv

METHOD
Locale.Gettext.gettext

SYNTAX
string gettext(string msg)

DESCRIPTION
Return a translated version of msg within the context of the current domain and locale. If there is not translation available, msg is returned.

ARGUMENTS
argument(s)description
string msg
The message to translate.

SEE ALSO
bindtextdomain, textdomain, dgettext, dcgettext, setlocale and localeconv

METHOD
Locale.Gettext.localeconv

SYNTAX
mapping localeconv()

DESCRIPTION
The localeconv() function returns a mapping with settings for the current locale. This mapping contains all values associated with the locale categories LC_NUMERIC and LC_MONETARY.

string decimal_point: The decimal-point character used to format non-monetary quantities.

string thousands_sep: The character used to separate groups of digits to the left of the decimal-point character in formatted non-monetary quantities.

string int_curr_symbol: The international currency symbol applicable to the current locale, left-justified within a four-character space-padded field. The character sequences should match with those specified in ISO 4217 Codes for the Representation of Currency and Funds.

string currency_symbol: The local currency symbol applicable to the current locale.

string mon_decimal_point: The decimal point used to format monetary quantities.

string mon_thousands_sep: The separator for groups of digits to the left of the decimal point in formatted monetary quantities.

string positive_sign: The string used to indicate a non-negative-valued formatted monetary quantity.

string negative_sign: The string used to indicate a negative-valued formatted monetary quantity.

int int_frac_digits: The number of fractional digits (those to the right of the decimal point) to be displayed in an internationally formatted monetary quantity.

int frac_digits: The number of fractional digits (those to the right of the decimal point) to be displayed in a formatted monetary quantity.

int p_cs_precedes: Set to 1 or 0 if the currency_symbol respectively precedes or succeeds the value for a non-negative formatted monetary quantity.

int p_sep_by_space: Set to 1 or 0 if the currency_symbol respectively is or is not separated by a space from the value for a non-negative formatted monetary quantity.

int n_cs_precedes: Set to 1 or 0 if the currency_symbol respectively precedes or succeeds the value for a negative formatted monetary quantity.

int n_sep_by_space: Set to 1 or 0 if the currency_symbol respectively is or is not separated by a space from the value for a negative formatted monetary quantity.

int p_sign_posn: Set to a value indicating the positioning of the positive_sign for a non-negative formatted monetary quantity. The value of p_sign_posn is interpreted according to the following:

0 - Parentheses surround the quantity and currency_symbol.

1 - The sign string precedes the quantity and currency_symbol.

2 - The sign string succeeds the quantity and currency_symbol.

3 - The sign string immediately precedes the currency_symbol.

4 - The sign string immediately succeeds the currency_symbol.

int n_sign_posn: Set to a value indicating the positioning of the negative_sign for a negative formatted monetary quantity. The value of n_sign_posn is interpreted according to the rules described under p_sign_posn.

SEE ALSO
bindtextdomain, textdomain, gettext, dgettext, dcgettext and setlocale

METHOD
Locale.Gettext.setlocale

SYNTAX
int setlocale(int category,  string locale)

DESCRIPTION
The setlocale() function is used to set the program's current locale. If locale is "C" or "POSIX", the current locale is set to the portable locale.

If locale is "", the locale is set to the default locale which is selected from the environment variable LANG.

The argument category determines which functions are influenced by the new locale: Locale.Gettext.LC_ALL for all of the locale.

Locale.Gettext.LC_COLLATE for the functions strcoll() and strxfrm() (used by pike, but not directly accessible).

Locale.Gettext.LC_CTYPE for the character classification and conversion routines.

Locale.Gettext.LC_MONETARY for localeconv(). Locale.Gettext.LC_NUMERIC for the decimal character. Locale.Gettext.LC_TIME for strftime() (currently not accessible from Pike).

ARGUMENTS
argument(s)description
int category
The category in which to set the locale.
string locale
The locale to change to

RETURNS
1 if the locale setting successed, 0 for failure

SEE ALSO
bindtextdomain, textdomain, gettext, dgettext, dcgettext and localeconv

METHOD
Locale.Gettext.textdomain

SYNTAX
string textdomain(string domain|void)
string textdomain(void)

DESCRIPTION
The textdomain() function sets or queries the name of the current domain of the active LC_MESSAGES locale category. The domainname argument is a string that can contain only the characters allowed in legal filenames.

The 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 bindtextdomain(). If textdomain() is not called, a default domain is selected. The setting of domain made by the last valid call to textdomain() remains valid across subsequent calls to setlocale, and gettext(). The normal return value from textdomain() is a string containing the current setting of the domain. If domainname is void, textdomain() returns a string containing the current domain. If textdomain() was not previously called and domainname is void, the name of the default domain is returned.

ARGUMENTS
argument(s)description
string domainname
The name of the domain to be made the current domain.

SEE ALSO
bindtextdomain, gettext, dgettext, dcgettext, setlocale and localeconv

Previous section To contents Next section