[−][src]Module locale_settings::locale
Provides ability to get/set the current process locale.
This module allows the client to fetch and set locales for different
Category
values, or for all. This is a core capability for clients
to be able to set the current locale for their process. If you only
plan to set the locale, get settings, and then reset the locale you
may want to look at the _for_locale
version of settings functions.
Example
use locale_types::{Locale, LocaleString}; use locale_settings::locale::{Category, get_locale, set_locale}; use std::str::FromStr; let old_locale = get_locale(&Category::Currency); if old_locale.is_ok() { if set_locale(&Locale::String(LocaleString::from_str("en_US").unwrap()), &Category::Currency) { // do something with new locale... if !set_locale(&old_locale.unwrap(), &Category::Currency) { panic!("Could not re-set the old locale"); } } else { panic!("Could not set the new locale"); } } else { panic!("Could not save the existing locale"); }
Enums
Category | The different categories for which locale information may be set. This implies that entirely different locales may be then specified for each category. |
Functions
get_locale | Get the locale for the |
set_locale | Set the locale to |
set_locale_all | Set all locale categories to |
set_locale_all_from_env | Set all locale categories, based on the |
set_locale_from_env | Set the locale for the |