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) -> Self
pub fn new(current_locale: LanguageIdentifier) -> Self
Creates a new TranslationMap.
Sourcepub fn add_translation(self, file: TranslationFile) -> Self
pub fn add_translation(self, file: TranslationFile) -> Self
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>>>
pub fn get_bundle( &self, locale: &LanguageIdentifier, ) -> Option<VarReadGuard<'_, FluentBundle<FluentResource>>>
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
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TranslationMap
impl !UnwindSafe for TranslationMap
impl Freeze for TranslationMap
impl Send for TranslationMap
impl Sync for TranslationMap
impl Unpin for TranslationMap
impl UnsafeUnpin for TranslationMap
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