pub struct Locale { /* private fields */ }
Expand description
Represent a Windows locale. Can be used to fetch a lot of information regarding the locale.
Use Locale::user
to fetch the current user local or Local::system
to fetch the system default locale. Using the first one is recommended.
use native_windows_gui as nwg;
let fr_locale = nwg::Locale::from_str("fr");
let en_us_locale = nwg::Locale::from_str("en-US");
let user_locale = nwg::Locale::user();
let locales: Vec<String> = nwg::Locale::all();
user_locale.display_name();
Implementations§
Source§impl Locale
impl Locale
Sourcepub fn new(name: String) -> Result<Locale, NwgError>
pub fn new(name: String) -> Result<Locale, NwgError>
Create a new local from a locale name. If you have a str, use from_str
instead.
Sourcepub fn from_str<'a>(name: &'a str) -> Result<Locale, NwgError>
pub fn from_str<'a>(name: &'a str) -> Result<Locale, NwgError>
Create a new local from a locale name. If you have a String, use new
instead.
Sourcepub fn display_name(&self) -> String
pub fn display_name(&self) -> String
Localized name of locale, eg “German (Germany)” in UI language
Sourcepub fn english_display_name(&self) -> String
pub fn english_display_name(&self) -> String
Display name (language + country/region usually) in English, eg “German (Germany)”
Sourcepub fn native_display_name(&self) -> String
pub fn native_display_name(&self) -> String
Display name in native locale language, eg “Deutsch (Deutschland)
Sourcepub fn country_name(&self) -> String
pub fn country_name(&self) -> String
Localized name of country/region, eg “Germany” in UI language
Sourcepub fn english_country_name(&self) -> String
pub fn english_country_name(&self) -> String
English name of country/region, eg “Germany”
Sourcepub fn native_country_name(&self) -> String
pub fn native_country_name(&self) -> String
Native name of country/region, eg “Deutschland”
Sourcepub fn dialing_code(&self) -> i32
pub fn dialing_code(&self) -> i32
country/region dialing code, example: en-US and en-CA return 1.
Sourcepub fn list_separator(&self) -> String
pub fn list_separator(&self) -> String
list item separator, eg “,” for “1,2,3,4”
Sourcepub fn measurement_system(&self) -> MeasurementSystem
pub fn measurement_system(&self) -> MeasurementSystem
Returns the measurement system (metric or imperial)
Sourcepub fn decimal_separator(&self) -> String
pub fn decimal_separator(&self) -> String
Returns the decimal separator, eg “.” for 1,234.00
Sourcepub fn thousand_separator(&self) -> String
pub fn thousand_separator(&self) -> String
Returns the thousand separator, eg “,” for 1,234.00
Sourcepub fn digit_grouping(&self) -> String
pub fn digit_grouping(&self) -> String
Returns the digit grouping, eg “3;0” for 1,000,000
Sourcepub fn fractional_digit(&self) -> i32
pub fn fractional_digit(&self) -> i32
Returns the number of fractional digits eg 2 for 1.00
Sourcepub fn leading_zeros(&self) -> i32
pub fn leading_zeros(&self) -> i32
Returns the number of leading zeros for decimal, 0 for .97, 1 for 0.97
Sourcepub fn negative_number_mode(&self) -> NegativeNumberMode
pub fn negative_number_mode(&self) -> NegativeNumberMode
Returns the negative number mode. See the documentation of NegativeNumberMode
Sourcepub fn native_digits(&self) -> String
pub fn native_digits(&self) -> String
Returns native digits for 0-9, eg “0123456789”
Sourcepub fn currency_symbol(&self) -> String
pub fn currency_symbol(&self) -> String
Returns the local monetary symbol, eg “$”
Sourcepub fn intl_monetary_symbol(&self) -> String
pub fn intl_monetary_symbol(&self) -> String
Returns the intl monetary symbol, eg “USD”
Sourcepub fn monetary_decimal_separator(&self) -> String
pub fn monetary_decimal_separator(&self) -> String
Returns the monetary decimal separator, eg “.” for 1,234.00
Sourcepub fn monetary_thousand_separator(&self) -> String
pub fn monetary_thousand_separator(&self) -> String
Returns the monetary thousand separator, eg “,” for 1,234.00
Sourcepub fn monetary_digit_grouping(&self) -> String
pub fn monetary_digit_grouping(&self) -> String
Returns the monetary digit grouping, eg “3;0” for 1,000,000
Sourcepub fn monetary_fractional_digit(&self) -> i32
pub fn monetary_fractional_digit(&self) -> i32
Returns the number local monetary digits eg 2 for $1.00
Sourcepub fn currency_mode(&self) -> PositiveCurrency
pub fn currency_mode(&self) -> PositiveCurrency
Returns the positive currency mode. See PositiveCurrency
Sourcepub fn negative_currency_mode(&self) -> NegativeCurrency
pub fn negative_currency_mode(&self) -> NegativeCurrency
Returns the negative positive currency mode. See NegativeCurrency
Sourcepub fn short_date(&self) -> String
pub fn short_date(&self) -> String
Returns the short date format string, eg “MM/dd/yyyy”
Sourcepub fn long_date(&self) -> String
pub fn long_date(&self) -> String
Returns the long date format string, eg “dddd, MMMM dd, yyyy”
Sourcepub fn calendar2(&self) -> Calendar
pub fn calendar2(&self) -> Calendar
Returns the type of calendar with a bit more precision. Ex: Calendar::GregorianUs
Sourcepub fn first_day_of_week(&self) -> i32
pub fn first_day_of_week(&self) -> i32
Returns the first day of week specifier, 0-6, 0=Monday, 6=Sunday
Sourcepub fn first_day_of_year(&self) -> FirstDayOfYear
pub fn first_day_of_year(&self) -> FirstDayOfYear
Returns the first day of year specifier. See FirstDayOfYear
Sourcepub fn iso_lang_name(&self) -> String
pub fn iso_lang_name(&self) -> String
ISO abbreviated language name, eg “en”
Sourcepub fn iso_country_name(&self) -> String
pub fn iso_country_name(&self) -> String
ISO abbreviated country/region name, eg “US”
Sourcepub fn currency_name(&self) -> String
pub fn currency_name(&self) -> String
Returns the english name of currency, eg “Euro”
Sourcepub fn native_currency_name(&self) -> String
pub fn native_currency_name(&self) -> String
Returns the native name of currency, eg “euro”
Sourcepub fn month_name(&self, month_index: u32) -> String
pub fn month_name(&self, month_index: u32) -> String
Return the localized month name. See month_name_abv
for the abbreviated version
Parameters: month_index: The month index. 1(January) to 12 (December) or 13 (if it exists).
Panics: This function will panic if month index in not in the 1-13 range.
Sourcepub fn month_name_abv(&self, month_index: u32) -> String
pub fn month_name_abv(&self, month_index: u32) -> String
Return the localized month name in an abbreviated version. See month_name
for the full version
Parameters: month_index: The month index. 1(January) to 12 (December) or 13 (if it exists).
Panics: This function will panic if month index in not in the 1-13 range.
Sourcepub fn day_name(&self, day_index: u32) -> String
pub fn day_name(&self, day_index: u32) -> String
Return the localized day name. See day_name_abv
for the abbreviated version
Parameters: day_index: The month index. 1(Monday) to 7 (Sunday)
Panics: This function will panic if month index in not in the 1-7 range.
Sourcepub fn day_name_abv(&self, day_index: u32) -> String
pub fn day_name_abv(&self, day_index: u32) -> String
Return the localized day name in an abbreviated version. See day_name
for the full version
Parameters: day_index: The month index. 1(Monday) to 7 (Sunday)
Panics: This function will panic if month index in not in the 1-7 range.