Skip to main content

Localizer

Struct Localizer 

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

Immutable access to eska’s embedded translations.

Implementations§

Source§

impl Localizer

Source

pub fn try_new(locale: Locale) -> Result<Self, LocalizationError>

Creates a localizer from the translation resource embedded in the binary.

§Errors

This can fail only if an embedded resource or its canonical locale identifier is invalid. Tests validate both resources so installation needs no external files.

Source

pub const fn locale(&self) -> Locale

Returns the locale used by this localizer.

Source

pub fn text(&self, key: &str) -> String

Resolves a translation without parameters.

Source

pub fn format( &self, key: &str, values: &[(&str, LocalizationValue<'_>)], ) -> String

Resolves a translation with named parameters.

Source§

impl Localizer

Source

pub fn property_caption( &self, owner: Option<MetadataKind>, key: &PropertyKey, ) -> Option<String>

Resolve contextual captions first, retaining QName boundaries for unknown extensions.

Source§

impl Localizer

Source

pub fn property_value_caption( &self, owner: MetadataKind, root: &PropertyKey, path: &[&PropertyKey], key: &PropertyKey, text: &str, ) -> Option<String>

Translate only a token belonging to the field’s known enum domain.

Source

pub fn enum_caption(&self, domain: &str, token: &str) -> Option<String>

Preserve unknown enum tokens, including future platform additions.

Source

pub fn typed_value_caption( &self, key: &PropertyKey, text: &str, ) -> Option<String>

XML value annotations select a closed enum domain independently of prefix spelling.

Source

pub fn type_caption(&self, key: &PropertyKey) -> Option<String>

Resolve built-in XML type names using namespace URIs, independent of prefix spelling.

Source

pub fn qualifier_caption( &self, field: &PropertyKey, qualifier: &PropertyKey, text: &str, ) -> Option<String>

Standard-attribute identities are platform vocabulary; arbitrary object names are not.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.