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 the
i18n module. The first resolver that returns Some wins; if all resolvers
return None, I18nConfig::default_locale is used.
§Empty-allowlist semantics
Built-in resolvers disagree on what an empty available_locales slice
means, so pick the constructor inputs deliberately:
QueryParamResolverandCookieResolvertreat an empty allowlist as “accept any value” — whatever the caller supplied is returned verbatim.AcceptLanguageResolvertreats an empty allowlist as “match nothing” because it can only return locales that appear in the list.
The default chain built by I18n::new hands every
resolver the same available_locales, so the asymmetry only surfaces when
wiring resolvers manually.