pub struct ClientTranslationsManager { /* private fields */ }
Expand description
Manages translations in the app shell. This handles fetching translations from the server as well as caching for performance.
This is distinct from TranslationsManager
in that it operates on the client-side rather than on the server. This optimizes for
users viewing many pages in the same locale, which is by far the most common use of most websites in terms of i18n.
Implementations
sourceimpl ClientTranslationsManager
impl ClientTranslationsManager
sourcepub fn new(locales: &Locales) -> Self
pub fn new(locales: &Locales) -> Self
Creates a new client-side translations manager that hasn’t cached anything yet. This needs to know about an app’s supported locales so it can avoid network requests to unsupported locales.
sourcepub async fn get_translator_for_locale(
&mut self,
locale: &str
) -> Result<&Translator, ClientError>
pub async fn get_translator_for_locale(
&mut self,
locale: &str
) -> Result<&Translator, ClientError>
Gets an &'static Translator
for the given locale. This will use the internally cached Translator
if possible, and will otherwise
fetch the translations from the server. This needs mutability because it will modify its internal cache if necessary.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ClientTranslationsManager
impl Send for ClientTranslationsManager
impl Sync for ClientTranslationsManager
impl Unpin for ClientTranslationsManager
impl UnwindSafe for ClientTranslationsManager
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more