Struct I18nConfig

Source
pub struct I18nConfig {
    pub id: LanguageIdentifier,
    pub fallback: Option<LanguageIdentifier>,
    pub locale_resources: Vec<LocaleResource>,
    pub locales: HashMap<LanguageIdentifier, usize>,
}
Expand description

The configuration for I18n.

Fields§

§id: LanguageIdentifier

The initial language, can be later changed with I18n::set_language

§fallback: Option<LanguageIdentifier>

The final fallback language if no other locales are found for id. A Locale must exist in locales' if fallback` is defined.

§locale_resources: Vec<LocaleResource>

The locale_resources added to the configuration.

§locales: HashMap<LanguageIdentifier, usize>

The locales added to the configuration.

Implementations§

Source§

impl I18nConfig

Source

pub fn new(id: LanguageIdentifier) -> Self

Create an i18n config with the selected LanguageIdentifier.

Source

pub fn with_fallback(self, fallback: LanguageIdentifier) -> Self

Set a fallback LanguageIdentifier.

Source

pub fn with_locale<T>(self, locale: T) -> Self
where T: Into<Locale>,

Add Locale. It is possible to share locales resources. If this locale’s resource matches a previously added one, then this locale will use the existing one. This is primarily for the static locale_resources to avoid string duplication.

Trait Implementations§

Source§

impl Debug for I18nConfig

Source§

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

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

impl PartialEq for I18nConfig

Source§

fn eq(&self, other: &I18nConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for I18nConfig

Auto Trait Implementations§

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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> ComponentProps for T
where T: Any + PartialEq,

Source§

fn changed(&self, other: &(dyn ComponentProps + 'static)) -> bool

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more