Skip to main content

IStringLocalizer

Trait IStringLocalizer 

Source
pub trait IStringLocalizer: Send + Sync {
    // Required methods
    fn default_culture(&self) -> &str;
    fn get_in(&self, culture: &str, key: &str) -> LocalizedString;

    // Provided methods
    fn get(&self, key: &str) -> LocalizedString { ... }
    fn resolve_in(&self, culture: &str, text: TextRef) -> LocalizedString { ... }
    fn resolve(&self, text: TextRef) -> LocalizedString { ... }
}
Expand description

Resolves resource keys for a culture.

The default implementation of Self::get and Self::resolve uses Self::default_culture, which the host sets from Culture.Default. Pass an explicit culture only for cross-culture output (for example a per-culture report); request handling should use the configured default.

Required Methods§

Source

fn default_culture(&self) -> &str

Culture used when no explicit culture is supplied.

Source

fn get_in(&self, culture: &str, key: &str) -> LocalizedString

Resolve key for culture, falling back through parent cultures to the default culture, then returning the key with resource_not_found.

Provided Methods§

Source

fn get(&self, key: &str) -> LocalizedString

Resolve key for the default culture.

Source

fn resolve_in(&self, culture: &str, text: TextRef) -> LocalizedString

Resolve a metadata text reference for culture.

Source

fn resolve(&self, text: TextRef) -> LocalizedString

Resolve a metadata text reference for the default culture.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§