FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    CultureInfo

    struct · ferroui-base · v0.5.0

    struct CultureInfo
    

    A culture: a locale, with the number and date conventions it formats with.

    Cloning is cheap (one reference count, and one more per attached conventions). Equality compares the names ignoring ASCII case: two cultures of the same locale are equal, the conventions attached to them are not compared.

    View source

    Members

    invariant_culture

    fn invariant_culture() -> CultureInfo
    

    The culture-independent (invariant) culture; its name is empty and its locale is the unknown locale und.

    Source

    from_locale

    fn from_locale(locale: Locale) -> CultureInfo
    

    The culture of a locale: its name is the BCP-47 text of the locale (en-US, zh-Hant-TW, en-US-u-hc-h12), its Windows language identifier the one of the locale where one is known (lcid), and its conventions the ones the registered ICultureDataProvider has for the locale or the nearest of its parents. The unknown locale und is the invariant culture.

    Source

    get_culture_info

    fn get_culture_info(name: &str) -> CultureInfo
    

    The culture for a name such as en-US (C# GetCultureInfo(string)). An empty name gives the invariant culture.

    A name that is a BCP-47 language tag gives the culture of its locale (from_locale), so the case of its subtags is normalized as .NET normalizes it (EN-us is en-US) and und is the invariant culture. A name that is not one (es-ES_tradnl, x-custom) gives a culture that keeps the name as it is, with the Windows language identifier of the name where one is known, and no locale.

    Source

    get_culture_info_by_ietf_language_tag

    fn get_culture_info_by_ietf_language_tag(name: &str) -> Option<CultureInfo>
    

    The culture for an IETF language tag (C# GetCultureInfoByIetfLanguageTag): the culture of the locale the tag is parsed into, the invariant culture for the empty tag, or None for a text that is not a BCP-47 language tag (C# throws CultureNotFoundException): the old names zh-CHT and zh-CHS, the traditional sort of Spanish es-ES_tradnl, a private name such as x-custom, a text with _ as separator.

    Source

    get_culture_info_by_lcid

    fn get_culture_info_by_lcid(lcid: i32) -> Option<CultureInfo>
    

    The culture for a Windows language identifier (C# GetCultureInfo(int)), or None when the identifier is not known (C# throws CultureNotFoundException).

    Source

    get_cultures

    fn get_cultures(types: CultureTypes) -> Vec<CultureInfo>
    

    The cultures of the given types (C# GetCultures).

    The managed runtime lists the cultures of its globalization library. The base library has the data of the invariant culture only, so the list is the one the registered ICultureDataProvider gives, the cultures of its locales (get_locales), preceded by the invariant culture when the neutral cultures are asked for. Without a provider the list is the invariant culture alone, whatever the types: what the managed runtime returns in its invariant globalization mode.

    Source

    locale

    fn locale(self: &Self) -> &Locale
    

    The locale of the culture: the unknown locale und for the invariant culture, and for a culture whose name is not a BCP-47 language tag (es-ES_tradnl), which has no locale of its own (the conversion Locale::try_from(&culture) refuses such a culture instead).

    Source

    name

    fn name(self: &Self) -> &str
    

    The name (C# Name): the BCP-47 text of the locale, empty for the invariant culture, or the name as it was given when it is not a BCP-47 tag.

    Source

    lcid

    fn lcid(self: &Self) -> i32
    

    The Windows language identifier (C# LCID): the one of the locale where one is known, 0x007F for the invariant culture, else 0x1000 (LOCALE_CUSTOM_UNSPECIFIED).

    Source

    two_letter_iso_language_name

    fn two_letter_iso_language_name(self: &Self) -> &str
    

    The primary language subtag (C# TwoLetterISOLanguageName); iv for the invariant culture.

    Source

    parent

    fn parent(self: &Self) -> CultureInfo
    

    The culture this one specializes (C# Parent): the culture of the parent of its locale, the locale without its last variant, else without its region, else without its script; the parent of a language-only culture is the invariant culture. Chinese regional cultures have their script culture as parent (zh-CN -> zh-Hans, zh-TW -> zh-Hant), as in .NET. A culture whose name is not a BCP-47 tag has the culture of its name without its last subtag as parent (es-ES_tradnl -> es-ES).

    Source

    is_invariant

    fn is_invariant(self: &Self) -> bool
    

    Whether this is the invariant culture.

    Source

    date_time_format

    fn date_time_format(self: &Self) -> Rc<DateTimeFormatInfo>
    

    The date and time conventions of the culture (C# DateTimeFormat): the ones attached with with_date_time_format, else the data the registered ICultureDataProvider has for the locale of the culture or the nearest of its parents, else the invariant conventions.

    Unlike .NET, the library itself carries the data of the invariant culture only.

    Source

    with_date_time_format

    fn with_date_time_format(self: &Self, date_time_format: DateTimeFormatInfo) -> CultureInfo
    

    A culture with the same identity and the given date and time conventions (the C# new CultureInfo(name) { DateTimeFormat = .. }).

    Source

    with_number_format

    fn with_number_format(self: &Self, number_format: NumberFormatInfo) -> CultureInfo
    

    A culture with the same identity and the given number conventions (the C# new CultureInfo(name) { NumberFormat = .. }).

    Source

    calendar

    fn calendar(self: &Self) -> GregorianCalendar
    

    The calendar of the culture (C# Calendar); always the Gregorian one.

    Source

    text_info

    fn text_info(self: &Self) -> Rc<super::TextInfo>
    

    The text conventions of the culture (C# TextInfo): the data the registered ICultureDataProvider has for the locale of the culture or the nearest of its parents, else the invariant conventions.

    Source

    number_format

    fn number_format(self: &Self) -> Rc<super::NumberFormatInfo>
    

    The number conventions of the culture (C# NumberFormat).

    Only the invariant conventions are built in: those of other cultures come from the provider registered with the locator (see ICultureDataProvider); a culture without data gets the conventions of its nearest parent that has data and finally the invariant ones.

    Source

    current_formatting

    fn current_formatting() -> CultureInfo
    

    The culture the current thread formats with (the conventions of .NET's CultureInfo.CurrentCulture): the culture of current_locale, with the conventions attached to it when it was set with set_current_formatting. Cloning it is cheap.

    Source

    set_current_formatting

    fn set_current_formatting(culture: CultureInfo)
    

    Sets the culture the current thread formats with, the conventions attached to it included, and the locale of the thread to the locale of the culture (CultureInfo::locale). A culture whose name is not a BCP-47 language tag (es-ES_tradnl, x-custom), which has no locale of its own, leaves the locale the unknown locale und while the thread formats with the culture as it is.

    A culture without attached conventions is the same as set_current_locale with its locale.

    Source

    current_culture

    fn current_culture() -> CultureInfo
    

    The culture used by the current thread.

    Deprecated since 0.5.0. use ferroui_base::utilities::current_locale for the language of the thread, or CultureInfo::current_formatting for the culture it formats with

    Source

    set_current_culture

    fn set_current_culture(culture: CultureInfo)
    

    Sets the culture used by the current thread.

    Deprecated since 0.5.0. use ferroui_base::utilities::set_current_locale, or CultureInfo::set_current_formatting for a culture with attached conventions

    Source

    current_ui_culture

    fn current_ui_culture() -> CultureInfo
    

    The user interface culture used by the current thread: the culture of current_ui_locale.

    Deprecated since 0.5.0. use ferroui_base::utilities::current_ui_locale

    Source

    set_current_ui_culture

    fn set_current_ui_culture(culture: CultureInfo)
    

    Sets the user interface culture used by the current thread: its locale, the unknown locale und for a culture whose name is not a BCP-47 language tag.

    Deprecated since 0.5.0. use ferroui_base::utilities::set_current_ui_locale

    Source

    compare_info

    fn compare_info(self: &Self) -> CompareInfo
    

    The comparer of the culture (C# CompareInfo): the rules the culture data provider has for the culture or for the nearest of its parents, and otherwise the built-in invariant rules.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.