[−][src]Module simple_locale::settings
Parent to a set of operating system, locale functions.
Typically we treat each of the categories defined by POSIX in locale.h
as
modules. The categories are show in the table below.
POSIX Category | Module | Function(s) |
---|---|---|
LC_COLLATE | N/A | |
LC_CTYPE | codeset | get_code_set_format , get_code_set_format_for_locale |
LC_MESSAGES | messages | get_message_format , get_message_format_for_locale |
LC_MONETARY | currency | get_currency_format , get_currency_format_for_locale |
LC_NUMERIC | numeric | get_numeric_format , get_numeric_format_for_locale |
LC_TIME | time | get_date_time_format , get_date_time_format_for_locale , get_calendar_names , get_calendar_names_for_locale |
Note: the POSIX category
LC_COLLATE
is not mapped to modules as there are no calls to retrieve specific information.
For each module there is at least a matching pair of functions, one which takes
zero parameters and returns the current locale settings, and one which takes
two parameters and allows the retrieval of settings from another locale. The first
of these parameters is a Locale
enum that denotes
the locale to query, and the second parameter is a boolean inherit_current
that
determines how the specified locale should be interpreted.
Additionally, the module locale
has the necessary functions
to get and set the locale either for an individual category or for all. This modules
provides implementations that use the C API directly as well as an implementation
that uses standard environment variables.
Relationship to the POSIX API
The POSIX locale API is spread across a number of functions including
localeconv
,
nl_langinfo
, and
setlocale
. Also, the
different categories of data is mixed up in common structures. The intent
of this crate is to invert this abstraction, to group together data by common
category regardless of the underlying API being used.
Those functions in the table above that end in _for_locale
use the xlocale
extended API, specifically
newlocale
,
uselocale
, and
freelocale
to obtain the settings
for a locale other than the current.
Modules
codeset | Fetch locale-specific code-set settings. |
currency | Fetch locale-specific currency formatting settings. |
locale | Provides ability to get/set the current process locale. |
messages | Fetch locale-specific message formatting settings. |
numeric | Fetch locale-specific number formatting settings. |
time | Fetch locale-specific date and time formatting settings. |