Struct Locale

Source
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

Source

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.

Source

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.

Source

pub fn all() -> Vec<String>

Return the identifier (ex: en-US) of every supported locales.

Source

pub fn user() -> Locale

Return the current user locale

Source

pub fn system() -> Locale

Return the current system locale

Source

pub fn name(&self) -> &str

Return the name of the locale.

Source

pub fn display_name(&self) -> String

Localized name of locale, eg “German (Germany)” in UI language

Source

pub fn english_display_name(&self) -> String

Display name (language + country/region usually) in English, eg “German (Germany)”

Source

pub fn native_display_name(&self) -> String

Display name in native locale language, eg “Deutsch (Deutschland)

Source

pub fn country_name(&self) -> String

Localized name of country/region, eg “Germany” in UI language

Source

pub fn english_country_name(&self) -> String

English name of country/region, eg “Germany”

Source

pub fn native_country_name(&self) -> String

Native name of country/region, eg “Deutschland”

Source

pub fn dialing_code(&self) -> i32

country/region dialing code, example: en-US and en-CA return 1.

Source

pub fn list_separator(&self) -> String

list item separator, eg “,” for “1,2,3,4”

Source

pub fn measurement_system(&self) -> MeasurementSystem

Returns the measurement system (metric or imperial)

Source

pub fn decimal_separator(&self) -> String

Returns the decimal separator, eg “.” for 1,234.00

Source

pub fn thousand_separator(&self) -> String

Returns the thousand separator, eg “,” for 1,234.00

Source

pub fn digit_grouping(&self) -> String

Returns the digit grouping, eg “3;0” for 1,000,000

Source

pub fn fractional_digit(&self) -> i32

Returns the number of fractional digits eg 2 for 1.00

Source

pub fn leading_zeros(&self) -> i32

Returns the number of leading zeros for decimal, 0 for .97, 1 for 0.97

Source

pub fn negative_number_mode(&self) -> NegativeNumberMode

Returns the negative number mode. See the documentation of NegativeNumberMode

Source

pub fn native_digits(&self) -> String

Returns native digits for 0-9, eg “0123456789”

Source

pub fn currency_symbol(&self) -> String

Returns the local monetary symbol, eg “$”

Source

pub fn intl_monetary_symbol(&self) -> String

Returns the intl monetary symbol, eg “USD”

Source

pub fn monetary_decimal_separator(&self) -> String

Returns the monetary decimal separator, eg “.” for 1,234.00

Source

pub fn monetary_thousand_separator(&self) -> String

Returns the monetary thousand separator, eg “,” for 1,234.00

Source

pub fn monetary_digit_grouping(&self) -> String

Returns the monetary digit grouping, eg “3;0” for 1,000,000

Source

pub fn monetary_fractional_digit(&self) -> i32

Returns the number local monetary digits eg 2 for $1.00

Source

pub fn currency_mode(&self) -> PositiveCurrency

Returns the positive currency mode. See PositiveCurrency

Source

pub fn negative_currency_mode(&self) -> NegativeCurrency

Returns the negative positive currency mode. See NegativeCurrency

Source

pub fn short_date(&self) -> String

Returns the short date format string, eg “MM/dd/yyyy”

Source

pub fn long_date(&self) -> String

Returns the long date format string, eg “dddd, MMMM dd, yyyy”

Source

pub fn time(&self) -> String

Returns the time format string, eg “HH:mm:ss”

Source

pub fn am(&self) -> String

Returns the AM designator, eg “AM”

Source

pub fn pm(&self) -> String

Returns the PM designator, eg “PM”

Source

pub fn calendar(&self) -> Calendar

Returns the type of calendar. Ex: Calendar::Gregorian

Source

pub fn calendar2(&self) -> Calendar

Returns the type of calendar with a bit more precision. Ex: Calendar::GregorianUs

Source

pub fn first_day_of_week(&self) -> i32

Returns the first day of week specifier, 0-6, 0=Monday, 6=Sunday

Source

pub fn first_day_of_year(&self) -> FirstDayOfYear

Returns the first day of year specifier. See FirstDayOfYear

Source

pub fn iso_lang_name(&self) -> String

ISO abbreviated language name, eg “en”

Source

pub fn iso_country_name(&self) -> String

ISO abbreviated country/region name, eg “US”

Source

pub fn currency_name(&self) -> String

Returns the english name of currency, eg “Euro”

Source

pub fn native_currency_name(&self) -> String

Returns the native name of currency, eg “euro”

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Locale

Source§

fn clone(&self) -> Locale

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Locale

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Locale

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Locale

§

impl RefUnwindSafe for Locale

§

impl Send for Locale

§

impl Sync for Locale

§

impl Unpin for Locale

§

impl UnwindSafe for Locale

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.