Skip to main content

EmbeddedI18n

Struct EmbeddedI18n 

Source
pub struct EmbeddedI18n { /* private fields */ }
Expand description

Explicit embedded localization context.

Construct this once during application startup, keep it in application state, and pass it to code that needs localization.

Implementations§

Source§

impl EmbeddedI18n

Source

pub fn try_new() -> Result<Self, EmbeddedInitError>

Builds an embedded context without selecting a language.

Source

pub fn try_new_with_language<L: Into<LanguageIdentifier>>( lang: L, ) -> Result<Self, EmbeddedInitError>

Builds an embedded context and selects the initial active language.

Source

pub fn try_new_with_language_strict<L: Into<LanguageIdentifier>>( lang: L, ) -> Result<Self, EmbeddedInitError>

Builds an embedded context and selects the initial active language, failing if any runtime module rejects the requested locale.

Source

pub fn select_language<L: Into<LanguageIdentifier>>( &self, lang: L, ) -> Result<(), LocalizationError>

Selects the active language for this context.

Concurrent selections through cloned handles are serialized. A failed selection preserves the previously active language and selection policy.

Source

pub fn select_language_strict<L: Into<LanguageIdentifier>>( &self, lang: L, ) -> Result<(), LocalizationError>

Selects the active language for this context and fails if any runtime module rejects the requested locale.

Shares the same serialized transition as Self::select_language.

Source

pub fn localize_message<T>(&self, message: &T) -> String
where T: FluentMessage + ?Sized,

Renders a derived typed message through this context.

Trait Implementations§

Source§

impl Clone for EmbeddedI18n

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl FluentLocalizer for EmbeddedI18n

Source§

fn localize<'a>( &self, key: StaticFluentMessageKey, args: Option<&FluentArgs<'a>>, ) -> Option<String>

Looks up a fully scoped static message key for a runtime integration. Read more
Source§

fn with_lookup(&self, f: &mut dyn FnMut(&mut FluentLocalizerLookup<'_>))

Runs a group of lookups against one render-scoped localization view. Read more

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
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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> FluentLocalizerExt for T
where T: FluentLocalizer + ?Sized,

Source§

fn try_localize_message<T>(&self, message: &T) -> Option<String>
where T: FluentMessage + ?Sized,

Attempts to render a derived typed message through this explicit localizer. Read more
Source§

fn localize_message<T>(&self, message: &T) -> String
where T: FluentMessage + ?Sized,

Renders a derived typed message through this explicit localizer. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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