[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.24.1 Internationalization with Guile
In order to make use of the functions described thereafter, the
(ice-9 i18n)
module must be imported in the usual way:
(use-modules (ice-9 i18n))
The (ice-9 i18n)
module provides procedures to manipulate text
and other data in a way that conforms to the cultural conventions
chosen by the user. Each region of the world or language has its own
customs to, for instance, represent real numbers, classify characters,
collate text, etc. All these aspects comprise the so-called
“cultural conventions” of that region or language.
Computer systems typically refer to a set of cultural conventions as a
locale. For each particular aspect that comprise those cultural
conventions, a locale category is defined. For instance, the
way characters are classified is defined by the LC_CTYPE
category, while the language in which program messages are issued to
the user is defined by the LC_MESSAGES
category
(see section General Locale Information for details).
The procedures provided by this module allow the development of
programs that adapt automatically to any locale setting. As we will
see later, many of these procedures can optionally take a locale
object argument. This additional argument defines the locale
settings that must be followed by the invoked procedure. When it is
omitted, then the current locale settings of the process are followed
(see section setlocale
).
The following procedures allow the manipulation of such locale objects.
- Scheme Procedure: make-locale category-list locale-name [base-locale]
- C Function: scm_make_locale (category_list, locale_name, base_locale)
Return a reference to a data structure representing a set of locale datasets. locale-name should be a string denoting a particular locale (e.g.,
"aa_DJ"
) and category-list should be either a list of locale categories or a single category as used withsetlocale
(see sectionsetlocale
). Optionally, ifbase-locale
is passed, it should be a locale object denoting settings for categories not listed in category-list.The following invocation creates a locale object that combines the use of Swedish for messages and character classification with the default settings for the other categories (i.e., the settings of the default
C
locale which usually represents conventions in use in the USA):(make-locale (list LC_MESSAGE LC_CTYPE) "sv_SE")
The following example combines the use of Esperanto messages and conventions with monetary conventions from Croatia:
(make-locale LC_MONETARY "hr_HR" (make-locale LC_ALL "eo_EO"))
A
system-error
exception (see section How to Handle Errors) is raised bymake-locale
when locale-name does not match any of the locales compiled on the system. Note that on non-GNU systems, this error may be raised later, when the locale object is actually used.
- Scheme Variable: %global-locale
- C Variable: scm_global_locale
This variable is bound to a locale object denoting the current process locale as installed using
setlocale ()
(see section Locales). It may be used like any other locale object, including as a third argument tomake-locale
, for instance.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on April 20, 2013 using texi2html 5.0.