pub struct MessageLocator { /* private fields */ }
Implementations§
Source§impl MessageLocator
impl MessageLocator
Sourcepub fn new(options: &MessageLocatorOptions) -> Self
pub fn new(options: &MessageLocatorOptions) -> Self
Constructs a MessageLocator
object.
Sourcepub fn supported_locales(&self) -> HashSet<Language>
pub fn supported_locales(&self) -> HashSet<Language>
Returns a set of supported locale codes, reflecting
the ones that were specified when constructing the MessageLocator
.
Sourcepub fn supports_locale(&self, arg: &Language) -> bool
pub fn supports_locale(&self, arg: &Language) -> bool
Returns true
if the locale is one of the supported locales
that were specified when constructing the MessageLocator
,
otherwise false
.
Sourcepub fn current_locale(&self) -> Option<Language>
pub fn current_locale(&self) -> Option<Language>
Returns the currently loaded locale.
Sourcepub fn current_locale_seq(&self) -> HashSet<Language>
pub fn current_locale_seq(&self) -> HashSet<Language>
Returns the currently loaded locale followed by its fallbacks or empty if no locale is loaded.
Sourcepub async fn update_locale(&mut self, new_locale: Language) -> bool
pub async fn update_locale(&mut self, new_locale: Language) -> bool
Attempts to load the specified locale and its fallbacks.
If any resource fails to load, the method returns false
, otherwise true
.
Sourcepub async fn load(&mut self, new_locale: Option<Language>) -> bool
pub async fn load(&mut self, new_locale: Option<Language>) -> bool
Attempts to load a locale and its fallbacks. If the locale argument is specified, it is loaded. Otherwise, if there is a default locale, it is loaded, and if not, the method panics.
If any resource fails to load, the method returns false
, otherwise true
.
Sourcepub fn get_formatted<S: ToString>(
&self,
id: S,
options: Vec<&dyn MessageLocatorFormatArgument>,
) -> String
pub fn get_formatted<S: ToString>( &self, id: S, options: Vec<&dyn MessageLocatorFormatArgument>, ) -> String
Retrieves message by identifier with formatting arguments.