pub struct Catalog { /* private fields */ }Expand description
Catalogues per locale and the locale in use.
A lookup names a key (id or id.attr) and tries the current
locale, then its parents (fr-CA, then fr), then English; what
English lacks too is None, and the caller shows its own English
text or the key. x-pseudo reads English, accented and lengthened.
Implementations§
Source§impl Catalog
impl Catalog
Sourcepub fn set_locale(&mut self, tag: &str)
pub fn set_locale(&mut self, tag: &str)
Switches the locale; the next lookups use it. A tag naming no language selects English.
Sourcepub fn add(&mut self, tag: &str, source: &str) -> Result<(), String>
pub fn add(&mut self, tag: &str, source: &str) -> Result<(), String>
Adds Fluent source to a locale’s catalogue. Refused, with nothing
added, when it does not parse or defines a message already there,
unless that message came from a base catalogue
(Catalog::add_base): the new text overrides it, and
Catalog::overridden says so.
Sourcepub fn add_base(&mut self, tag: &str, source: &str) -> Result<(), String>
pub fn add_base(&mut self, tag: &str, source: &str) -> Result<(), String>
Adds a base catalogue (egui-pop’s own): an application’s catalogue added after it may override its messages, with a warning.
Sourcepub fn overridden(&self) -> &[(String, String)]
pub fn overridden(&self) -> &[(String, String)]
The base messages an application’s catalogue overrode: (locale, id), in order.
Sourcepub fn add_overriding(&mut self, tag: &str, source: &str) -> Result<(), String>
pub fn add_overriding(&mut self, tag: &str, source: &str) -> Result<(), String>
Adds Fluent source whose messages replace those already there (an override directory over the embedded catalogues).
Sourcepub fn add_owned(
&mut self,
owner: &str,
tag: &str,
source: &str,
) -> Result<(), String>
pub fn add_owned( &mut self, owner: &str, tag: &str, source: &str, ) -> Result<(), String>
Adds a plugin’s Fluent source: every message must belong to
owner (see owned_by); a plugin translates its own commands,
panels and settings, never another’s.
Sourcepub fn find(
&self,
key: &str,
args: Option<&FluentArgs<'_>>,
) -> Option<(String, String)>
pub fn find( &self, key: &str, args: Option<&FluentArgs<'_>>, ) -> Option<(String, String)>
The text of key along the chain, with the locale that had it.
Sourcepub fn get(&self, key: &str, args: Option<&FluentArgs<'_>>) -> Option<String>
pub fn get(&self, key: &str, args: Option<&FluentArgs<'_>>) -> Option<String>
The text of key along the chain, English included.
Sourcepub fn get_in(
&self,
locale: &str,
key: &str,
args: Option<&FluentArgs<'_>>,
) -> Option<String>
pub fn get_in( &self, locale: &str, key: &str, args: Option<&FluentArgs<'_>>, ) -> Option<String>
The text of key in one locale’s chain (not the current one).
Sourcepub fn translated(&self, key: &str) -> bool
pub fn translated(&self, key: &str) -> bool
Whether the current locale’s own language has key: English’s
text, shown for a missing translation, does not count (unless the
locale is English).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Catalog
impl !RefUnwindSafe for Catalog
impl Send for Catalog
impl Sync for Catalog
impl Unpin for Catalog
impl UnsafeUnpin for Catalog
impl !UnwindSafe for Catalog
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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