Skip to main content

Strings

Trait Strings 

Source
pub trait Strings: Send + Sync {
    // Required method
    fn get(&self, key: &str) -> Option<String>;

    // Provided methods
    fn get_args(&self, key: &str, args: &[(&str, Arg<'_>)]) -> Option<String> { ... }
    fn language(&self) -> &str { ... }
    fn number(&self, value: f64, decimals: usize) -> Option<String> { ... }
    fn quantity(&self, number: &str, unit: &str) -> Option<String> { ... }
}
Expand description

Gives the text of a key in the current language, if it has one.

Required Methods§

Source

fn get(&self, key: &str) -> Option<String>

The text for a key; None falls back to English.

Provided Methods§

Source

fn get_args(&self, key: &str, args: &[(&str, Arg<'_>)]) -> Option<String>

The text for a key with its arguments placed; None falls back to English. By default Strings::get with its { $name } placeholders filled; a provider formatting its own (plurals, numbers) overrides it.

Text arguments (Arg::Str) are placed verbatim; only numbers (Arg::Num) may be formatted.

Source

fn language(&self) -> &str

The language, as a BCP 47 tag.

Source

fn number(&self, value: f64, decimals: usize) -> Option<String>

A number as the language writes it, with exactly decimals digits after the separator and its thousands grouped; None writes it as Rust does (1234.50). A provider that knows the locale’s separators overrides it.

Source

fn quantity(&self, number: &str, unit: &str) -> Option<String>

A number already written (by Strings::number) followed by its unit (EV, px, %), with the space the language puts between them: French puts a narrow no-break space. None puts a plain space, as English does.

Implementors§