Codex

gettext

Section: User Contributed Perl Documentation (3pm)

Updated: 2014-08-15

Index?action=index Return to Main Contents


NAME

Locale::gettext - message handling functions

SYNOPSIS

DESCRIPTION

The gettext module permits access from perl to the gettext() family of functions for retrieving message strings from databases constructed to internationalize software.

$d = Locale
:gettext->domain(DOMAIN)
$d = Locale
:gettext->domain_raw(DOMAIN):Creates a new object for retrieving strings in the domain DOMAIN and returns it. requests that strings be returned as Perl strings (possibly with wide characters) if possible while requests that octet strings directly from functions like .:
$d->get(MSGID)
Calls to return the translated string for the given MSGID.:
$d->cget(MSGID, CATEGORY)
Calls to return the translated string for the given MSGID in the given CATEGORY.:
$d->nget(MSGID, MSGID_PLURAL, N)
Calls to return the translated string for the given MSGID or MSGID_PLURAL depending on N.:
$d->ncget(MSGID, MSGID_PLURAL, N, CATEGORY)
Calls to return the translated string for the given MSGID or MSGID_PLURAL depending on N in the given CATEGORY.:
$d->dir([NEWDIR])
If NEWDIR is given, calls to set the name of the directory where messages for the domain represented by are found. Returns the (possibly changed) current directory name.:
$d->codeset([NEWCODE])
For instances created with , manuiplates the character set of the returned strings. If NEWCODE is given, calls to set the character encoding in which messages for the domain represented by are returned. Returns the (possibly changed) current encoding name.:
gettext(), dgettext(), and dcgettext() attempt to retrieve a string matching their parameter within the context of the current locale. dcgettext() takes the message's category and the text domain as parameters while dgettext() defaults to the LC_MESSAGES category and gettext() defaults to LC_MESSAGES and uses the current text domain. If the string is not found in the database, then is returned.

ngettext(), dngettext(), and dcngettext() function similarily but implement differentiation of messages between singular and plural. See the documentation for the corresponding C functions for details.

textdomain() sets the current text domain and returns the previously active domain.

bindtextdomain(domain, dirname) instructs the retrieval functions to look for the databases belonging to domain in the directory

bind_textdomain_codeset(domain, codeset) instructs the retrieval functions to translate the returned messages to the character encoding given by codeset if the encoding of the message catalog is known.

NOTES

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.

Perl programs should use the object interface. In addition to being able to return native Perl wide character strings, will be emulated if the C library does not provide it.

VERSION

1.05.

SEE ALSO

(3i), gettext?(1), msgfmt?(1)

AUTHOR

Phillip Vandry <[email protected]>


Index

NAME

SYNOPSIS

DESCRIPTION

NOTES

VERSION

SEE ALSO

AUTHOR