pub struct TranslationMap { /* private fields */ }Expand description
The global set of all translations for an application.
It maps the current locale to a TranslationFile.
The contents are stored in an Arc<T> so it’s cheap to clone.
Implementations§
Source§impl TranslationMap
impl TranslationMap
Sourcepub fn new(current_locale: LanguageIdentifier) -> TranslationMap
pub fn new(current_locale: LanguageIdentifier) -> TranslationMap
Creates a new TranslationMap.
Sourcepub fn add_translation(self, file: TranslationFile) -> TranslationMap
pub fn add_translation(self, file: TranslationFile) -> TranslationMap
Adds a new translation file to the map so it can be used by the application.
Sourcepub fn get_bundle(
&self,
locale: &LanguageIdentifier,
) -> Option<VarReadGuard<'_, FluentBundle<FluentResource, IntlLangMemoizer>>>
pub fn get_bundle( &self, locale: &LanguageIdentifier, ) -> Option<VarReadGuard<'_, FluentBundle<FluentResource, IntlLangMemoizer>>>
Returns a FluentBundle for the requested locale, if available.
Sourcepub fn get_current_locale(&self) -> VarReadGuard<'_, LanguageIdentifier>
pub fn get_current_locale(&self) -> VarReadGuard<'_, LanguageIdentifier>
Returns the locale that will be used to resolve strings.
Sourcepub fn set_current_locale(&mut self, locale: LanguageIdentifier)
pub fn set_current_locale(&mut self, locale: LanguageIdentifier)
Sets the locale that will be used to resolve strings.
Sourcepub fn reload(&mut self) -> Result<bool, (bool, Vec<Error>)>
pub fn reload(&mut self) -> Result<bool, (bool, Vec<Error>)>
Reloads any files that have been modified since they were last loaded.
Returns true if any of the files were successfully reloaded.
§Errors
The method will return a boolean irrelevant of errors, but in case of errors,
the Err variant will also contain a Vec of any io errors encountered.
Trait Implementations§
Source§impl Clone for TranslationMap
impl Clone for TranslationMap
Source§fn clone(&self) -> TranslationMap
fn clone(&self) -> TranslationMap
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for TranslationMap
impl Default for TranslationMap
Source§fn default() -> TranslationMap
fn default() -> TranslationMap
Creates a TranslationMap with the system’s locale. Defaults to “en-US” if getting the system’s locale fails.