pub struct Catalogs { /* private fields */ }Expand description
Every language’s catalog and the default language.
Implementations§
Source§impl Catalogs
impl Catalogs
Sourcepub fn new(default: &str) -> Catalogs
pub fn new(default: &str) -> Catalogs
No catalogs yet; default is the language used when a request asks
for none of them (and for keys a language lacks).
Sourcepub fn add(self, language: &str, text: &str) -> Result<Catalogs, String>
pub fn add(self, language: &str, text: &str) -> Result<Catalogs, String>
Add (or replace) language’s catalog from its text.
Sourcepub fn from_dir(
dir: impl AsRef<Path>,
default: &str,
) -> Result<Catalogs, String>
pub fn from_dir( dir: impl AsRef<Path>, default: &str, ) -> Result<Catalogs, String>
Every <language>.toml in dir; default as in Catalogs::new.
Sourcepub fn negotiate(&self, preferences: &AcceptLanguage) -> &str
pub fn negotiate(&self, preferences: &AcceptLanguage) -> &str
The language to answer in for these preferences.
Sourcepub fn for_request(&self, request: &Request) -> Translator<'_>
pub fn for_request(&self, request: &Request) -> Translator<'_>
A translator for the request’s Accept-Language.
Sourcepub fn translator(&self, accept_language: &str) -> Translator<'_>
pub fn translator(&self, accept_language: &str) -> Translator<'_>
A translator for an Accept-Language value.
Sourcepub fn for_preferences(&self, preferences: &AcceptLanguage) -> Translator<'_>
pub fn for_preferences(&self, preferences: &AcceptLanguage) -> Translator<'_>
A translator for parsed preferences.
Sourcepub fn for_language(&self, language: &str) -> Translator<'_>
pub fn for_language(&self, language: &str) -> Translator<'_>
A translator for one language (a user’s saved choice, say).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Catalogs
impl RefUnwindSafe for Catalogs
impl Send for Catalogs
impl Sync for Catalogs
impl Unpin for Catalogs
impl UnsafeUnpin for Catalogs
impl UnwindSafe for Catalogs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Available on crate feature
map-response-body only.Apply a transformation to the response body. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Available on crate feature
trace only.High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Available on crate feature
trace only.High level tracing that classifies responses using gRPC headers. Read more