# CultureInfo

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/struct-cultureinfo/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L101)

## Members

- [`invariant_culture`](#function-invariant_culture)
- [`from_locale`](#function-from_locale)
- [`get_culture_info`](#function-get_culture_info)
- [`get_culture_info_by_ietf_language_tag`](#function-get_culture_info_by_ietf_language_tag)
- [`get_culture_info_by_lcid`](#function-get_culture_info_by_lcid)
- [`get_cultures`](#function-get_cultures)
- [`locale`](#function-locale)
- [`name`](#function-name)
- [`lcid`](#function-lcid)
- [`two_letter_iso_language_name`](#function-two_letter_iso_language_name)
- [`parent`](#function-parent)
- [`is_invariant`](#function-is_invariant)
- [`date_time_format`](#function-date_time_format)
- [`with_date_time_format`](#function-with_date_time_format)
- [`with_number_format`](#function-with_number_format)
- [`calendar`](#function-calendar)
- [`text_info`](#function-text_info)
- [`number_format`](#function-number_format)
- [`current_formatting`](#function-current_formatting)
- [`set_current_formatting`](#function-set_current_formatting)
- [`current_culture`](#function-current_culture)
- [`set_current_culture`](#function-set_current_culture)
- [`current_ui_culture`](#function-current_ui_culture)
- [`set_current_ui_culture`](#function-set_current_ui_culture)
- [`compare_info`](#function-compare_info)

<a id="function-invariant_culture"></a>

### invariant_culture

```rust
fn invariant_culture() -> CultureInfo
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L118)

<a id="function-from_locale"></a>

### from_locale

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L131)

<a id="function-get_culture_info"></a>

### get_culture_info

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L152)

<a id="function-get_culture_info_by_ietf_language_tag"></a>

### get_culture_info_by_ietf_language_tag

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L174)

<a id="function-get_culture_info_by_lcid"></a>

### get_culture_info_by_lcid

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L183)

<a id="function-get_cultures"></a>

### get_cultures

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L203)

<a id="function-locale"></a>

### locale

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L221)

<a id="function-name"></a>

### name

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L236)

<a id="function-lcid"></a>

### lcid

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L244)

<a id="function-two_letter_iso_language_name"></a>

### two_letter_iso_language_name

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L250)

<a id="function-parent"></a>

### parent

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L270)

<a id="function-is_invariant"></a>

### is_invariant

```rust
fn is_invariant(self: &Self) -> bool
```

Whether this is the invariant culture.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L303)

<a id="function-date_time_format"></a>

### date_time_format

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L316)

<a id="function-with_date_time_format"></a>

### with_date_time_format

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L325)

<a id="function-with_number_format"></a>

### with_number_format

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L331)

<a id="function-calendar"></a>

### calendar

```rust
fn calendar(self: &Self) -> GregorianCalendar
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L336)

<a id="function-text_info"></a>

### text_info

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L344)

<a id="function-number_format"></a>

### number_format

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/culture_info.rs#L357)

<a id="function-current_formatting"></a>

### current_formatting

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/current_locale.rs#L71)

<a id="function-set_current_formatting"></a>

### set_current_formatting

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/current_locale.rs#L83)

<a id="function-current_culture"></a>

### current_culture

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/current_locale.rs#L93)

<a id="function-set_current_culture"></a>

### set_current_culture

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/current_locale.rs#L102)

<a id="function-current_ui_culture"></a>

### current_ui_culture

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/current_locale.rs#L109)

<a id="function-set_current_ui_culture"></a>

### set_current_ui_culture

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/current_locale.rs#L116)

<a id="function-compare_info"></a>

### compare_info

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/compare_info.rs#L282)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ResourceKeyObject`](/docs/0.5.0/api/ferroui-base/controls/trait-resourcekeyobject/)
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `PartialEq`
- `Eq`
- `Hash`
- `Display`
- `Debug`
- `TryFrom<&CultureInfo>`
- `From<&Locale>`
- `From<Locale>`
- [`DateTimeFormatProvider`](/docs/0.5.0/api/ferroui-base/utilities/trait-datetimeformatprovider/)
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- [`ValueTypeRegistration`](/docs/0.5.0/api/ferroui-base/data/core/trait-valuetyperegistration/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
