Struct perseus::ClientTranslationsManager [−][src]
pub struct ClientTranslationsManager { /* fields omitted */ }
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
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.
pub async fn get_translator_for_locale(
&mut self,
locale: &str
) -> Result<Rc<Translator>, ClientError>
pub async fn get_translator_for_locale(
&mut self,
locale: &str
) -> Result<Rc<Translator>, ClientError>
Gets an Rc<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.