bindtextdomain(DOMAIN, LOCALEDIR)
Register a text domain with a locale directory. Returns "LOCALEDIR" itself. If "LOCALEDIR" is
omitted, the registered locale directory of "DOMAIN" is returned. This method always success.
textdomain(DOMAIN)
Set the current text domain. Returns the "DOMAIN" itself. if "DOMAIN" is omitted, the current text
domain is returned. This method always success.
get_handle(@languages)
Set the language of the user. It searches for an available language in the provided @languages list.
If @languages was not provided, it looks checks environment variable LANG, and HTTP_ACCEPT_LANGUAGE
when running as CGI. Refer to Locale::Maketext(3) for the magic of the "get_handle".
$message = maketext($key, @param...)
Attempts to translate a text message into the native language of the user, by looking up the
translation in an MO lexicon file. Refer to Locale::Maketext(3) for the "maketext" plural grammar.
$message = __($key, @param...)
A synonym to "maketext()". This is a shortcut to "maketext()" so that it is cleaner when you employ
maketext to your existing project.
($key, @param...) = N_($key, @param...)
Returns the original text untouched. This is to enable the text be caught with xgettext.
$message = dmaketext($domain, $key, @param...)
Temporarily switch to another text domain and attempts to translate a text message into the native
language of the user in that text domain. Use "--keyword=dmaketext:2" for the xgettext utility.
$message = pmaketext($context, $key, @param...)
Attempts to translate a text message in a particular context into the native language of the user.
Use "--keyword=pmaketext:1c,2" for the xgettext utility.
$message = dpmaketext($domain, $context, $key, @param...)
Temporarily switch to another text domain and attempts to translate a text message in a particular
context into the native language of the user in that text domain. Use "--keyword=dpmaketext:2c,3"
for the xgettext utility.
encoding(ENCODING)
Set or retrieve the output encoding. The default is the same encoding as the gettext MO file. You
can specify "undef", to return the result in unencoded UTF-8.
key_encoding(ENCODING)
Specify the encoding used in your original text. The "maketext" method itself is not multibyte-safe
to the _AUTO lexicon. If you are using your native non-English language as your original text and
you are having troubles like:
Unterminated bracket group, in:
Then, specify the "key_encoding" to the encoding of your original text. Returns the current setting.
WARNING: You should always use US-ASCII text keys. Using non-US-ASCII keys is always discouraged and
is not guaranteed to be working.
encode_failure(CHECK)
Set the action when encode fails. This happens when the output text is out of the scope of your
output encoding. For example, output Chinese into US-ASCII. Refer to Encode(3) for the possible
values of this "CHECK". The default is "FB_DEFAULT", which is a safe choice that never fails. But
part of your text may be lost, since that is what "FB_DEFAULT" does. Returns the current setting.
die_for_lookup_failures(SHOULD_I_DIE)
Maketext dies for lookup failures, but GNU gettext never fails. By default
Lexicon::Maketext::Gettext follows the GNU gettext behavior. But if you are Maketext-styled, or if
you need a better control over the failures (like me :p), set this to 1. Returns the current
setting.
reload_text()
Purges the MO text cache. By default MO files are cached after they are read and parsed from the
disk, to reduce I/O and parsing overhead on busy sites. reload_text() purges this cache, so that
updated MO files can take effect at run-time. This is used when your MO file is updated, but you
cannot shutdown and restart the application. for example, when you are a virtual host on a
mod_perl-enabled Apache, or when your mod_perl-enabled Apache is too vital to be restarted for every
update of your MO file, or if you are running a vital daemon, such as an X display server.
%Lexicon = read_mo($MO_file)
Read and parse the MO file. Returns the read %Lexicon. The returned lexicon is in its original
encoding.
If you need the meta information of your MO file, parse the entry $Lexicon{""}. For example:
/^Content-Type: text\/plain; charset=(.*)$/im;
$encoding = $1;