pub struct LocaleMessages { /* private fields */ }Expand description
Container for locale-specific diagnostic messages.
Implementations§
Source§impl LocaleMessages
impl LocaleMessages
Sourcepub fn load(locale_id: &str) -> Option<Self>
pub fn load(locale_id: &str) -> Option<Self>
Load a locale from the embedded locale files.
Returns None if the locale is not supported or fails to parse.
Sourcepub fn get_message<'a>(&self, code: u32, fallback: &'a str) -> &'a str
pub fn get_message<'a>(&self, code: u32, fallback: &'a str) -> &'a str
Get the translated message for a diagnostic code.
Returns the translated message if available, otherwise returns the fallback.
Sourcepub fn get_message_owned(&self, code: u32, fallback: &str) -> String
pub fn get_message_owned(&self, code: u32, fallback: &str) -> String
Get the translated message for a diagnostic code, returning an owned String.
Returns the translated message if available, otherwise returns the fallback.
Sourcepub fn has_translation(&self, code: u32) -> bool
pub fn has_translation(&self, code: u32) -> bool
Check if this locale has a translation for the given code.
Sourcepub const fn is_default(&self) -> bool
pub const fn is_default(&self) -> bool
Returns true if this is the default (English) locale.
Trait Implementations§
Source§impl Debug for LocaleMessages
impl Debug for LocaleMessages
Source§impl Default for LocaleMessages
impl Default for LocaleMessages
Source§fn default() -> LocaleMessages
fn default() -> LocaleMessages
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LocaleMessages
impl RefUnwindSafe for LocaleMessages
impl Send for LocaleMessages
impl Sync for LocaleMessages
impl Unpin for LocaleMessages
impl UnsafeUnpin for LocaleMessages
impl UnwindSafe for LocaleMessages
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more