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: LanguageIdentifierThe 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
impl I18nConfig
Sourcepub fn new(id: LanguageIdentifier) -> Self
pub fn new(id: LanguageIdentifier) -> Self
Create an i18n config with the selected LanguageIdentifier.
Sourcepub fn with_fallback(self, fallback: LanguageIdentifier) -> Self
pub fn with_fallback(self, fallback: LanguageIdentifier) -> Self
Set a fallback LanguageIdentifier.
Sourcepub fn with_locale<T>(self, locale: T) -> Self
pub fn with_locale<T>(self, locale: T) -> Self
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
impl Debug for I18nConfig
Source§impl PartialEq for I18nConfig
impl PartialEq for I18nConfig
impl StructuralPartialEq for I18nConfig
Auto Trait Implementations§
impl Freeze for I18nConfig
impl RefUnwindSafe for I18nConfig
impl Send for I18nConfig
impl Sync for I18nConfig
impl Unpin for I18nConfig
impl UnwindSafe for I18nConfig
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ComponentProps for T
impl<T> ComponentProps for T
fn changed(&self, other: &(dyn ComponentProps + 'static)) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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