pub struct I18n { /* private fields */ }Expand description
Internationalization lookup table for UI strings, loaded from embedded JSON locale files.
Implementations§
Source§impl I18n
impl I18n
Sourcepub fn new(language: &str) -> Self
pub fn new(language: &str) -> Self
Create an I18n instance for the given BCP 47 language tag.
Resolution order:
- Exact match after alias normalisation (e.g.
"el","x-klingon") - Base subtag (e.g.
"pt-BR"→"pt") - English fallback
Sourcepub fn get<'a>(&'a self, key: &'a str) -> &'a str
pub fn get<'a>(&'a self, key: &'a str) -> &'a str
Return the localised string for key, or key itself if not found.
Sourcepub fn known_languages() -> impl Iterator<Item = &'static str>
pub fn known_languages() -> impl Iterator<Item = &'static str>
Return an iterator over all known language codes (for tooling / docs).
Auto Trait Implementations§
impl Freeze for I18n
impl RefUnwindSafe for I18n
impl Send for I18n
impl Sync for I18n
impl Unpin for I18n
impl UnsafeUnpin for I18n
impl UnwindSafe for I18n
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