Skip to main content

LocaleResolver

Trait LocaleResolver 

Source
pub trait LocaleResolver: Send + Sync {
    // Required method
    fn resolve(&self, parts: &Parts) -> Option<String>;
}
Expand description

Trait for extracting the active locale from a request.

Implementations are tried in order within the locale chain built by EngineBuilder::locale_resolvers. The first resolver that returns Some wins; if all resolvers return None, TemplateConfig::default_locale is used.

The resolved locale is stored in the request’s TemplateContext under the key "locale" and is available in every template as {{ locale }}.

Required Methods§

Source

fn resolve(&self, parts: &Parts) -> Option<String>

Returns a locale string (e.g. "en", "uk") if this resolver can determine the locale from the request, or None to fall through to the next resolver.

Implementors§