|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
text.gettext- Localized messages
This module provides utilities to deal with localized messages. The API is compatible to GNU’s gettext, and the messages are read from ‘*.po’ and ‘*.mo’ files, so that you can use the GNU gettext toolchain to prepare localized messages. However, the code is written from scratch by Alex Shinn and doesn’t depend on GNU’s gettext library.
This implementation extends GNU’s gettext API in the following ways:
SRFI-29 (See section
srfi-29 - Localization) provides another means of message
localization. A portable program may wish to use srfi-29, but
text.gettext is recommended in Gauche scripts
because of its flexibility and compatibility to existing message files.
Sets up the default domain and other parameters for
the application. The setting affects to the following
Domain is a string or list of strings specifying the domain
(name of ‘.mo’ or ‘.po’ files) as in C gettext.
You can pass
#f as domain-name just to get the default
domain accessor procedure.
You can alo pass multiple domains to domain-name.
(textdomain '("myapp" "gimp")) ; search 1st myapp, then gimp (gettext "/File/Close") ; "Close" from gimp unless overridden
Locale is a string or list of strings in the standard Unix format of
LANG[_REGION][.ENCODING]. You can also pass a list of locales
to specify fallbacks.
(textdomain "myapp" '("ru" "uk")) ; search 1st Russian then Ukranian, (gettext "Hello, World!") ; which are somewhat similar
Dirs is the search path of directories which should hold the
‘LOCALE/CDIR/’ directories which contain the actual message catalogs.
This is always appended with the system default, e.g.
‘"/usr/share/locale"’, and may also inherit from the
GETTEXT_PATH colon-delimited environment variable.
Cdir is the category directory, defaulting to either the
environment variable or the appropriate system default
LC_MESSAGES). You generally won’t need this.
means to cache individual messages, and defaults to
means to cache the lookup dispatch generated by these
parameters, and defaults to
Textdomain just passes these parameters to the internal
and binds the result to the global dispatch used by
You may build these closures manually for convenience in using multiple
separate domains or locales at once (useful for server environments).
See the description of
Textdomain returns an accessor procedure which
packages information of the domain. See
for the details.
Returns a translated message of msg-id. If there’s no translated message, msg-id itself is returned.
Similar to gettext, but it can be used to handle
Pass a singular form to msg-id, and plural form to
msg-id2. The num argument is used to determine
the plural form. If no message catalog is found, msg-id
is returned when num is 1, and msg-id2 otherwise.
Sets the search path of domain domain to dirs, which may be just a single directory name or a list of directory names.
Returns a translated message of msg-id in domain.
Dcgettext takes locale as well.
The following procedure is more flexible interface, on top of which the gettext-compatible APIs are written.
Creates and returns an accessor procedure, which encapsulates methods to retrieve localized messages.
The meaning of arguments are the same as
textdomain just calls
make-gettext, and later
it binds the result to the global parameter. If you wish to have
multiple independent domains within a single program, you can
make-gettext directly and manage the created
accessor procedure by yourself.
(define my-gettext (make-gettext "myapp")) (define _ (my-gettext 'getter)) (_ "Hello, World!")
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]|
This document was generated on July 19, 2014 using texi2html 1.82.