pub struct Locale(pub Locale);Expand description
An ICU4X Locale, capable of representing strings like "en-US".
Tuple Fields§
§0: LocaleImplementations§
Source§impl Locale
impl Locale
Sourcepub fn from_string(name: &DiplomatStr) -> Result<Box<Locale>, LocaleParseError>
pub fn from_string(name: &DiplomatStr) -> Result<Box<Locale>, LocaleParseError>
Construct an Locale from an locale identifier.
This will run the complete locale parsing algorithm. If code size and
performance are critical and the locale is of a known shape (such as
aa-BB) use create_und, set_language, set_script, and set_region.
Sourcepub fn basename(&self, write: &mut DiplomatWrite)
pub fn basename(&self, write: &mut DiplomatWrite)
Returns a string representation of the LanguageIdentifier part of
Locale.
Sourcepub fn get_unicode_extension(
&self,
s: &DiplomatStr,
write: &mut DiplomatWrite,
) -> Option<()>
pub fn get_unicode_extension( &self, s: &DiplomatStr, write: &mut DiplomatWrite, ) -> Option<()>
Returns a string representation of the unicode extension.
Sourcepub fn set_unicode_extension(
&mut self,
k: &DiplomatStr,
v: &DiplomatStr,
) -> Option<()>
pub fn set_unicode_extension( &mut self, k: &DiplomatStr, v: &DiplomatStr, ) -> Option<()>
Set a Unicode extension.
Sourcepub fn language(&self, write: &mut DiplomatWrite)
pub fn language(&self, write: &mut DiplomatWrite)
Returns a string representation of Locale language.
Sourcepub fn set_language(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
pub fn set_language(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
Set the language part of the Locale.
Sourcepub fn region(&self, write: &mut DiplomatWrite) -> Option<()>
pub fn region(&self, write: &mut DiplomatWrite) -> Option<()>
Returns a string representation of Locale region.
Sourcepub fn set_region(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
pub fn set_region(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
Set the region part of the Locale.
Sourcepub fn script(&self, write: &mut DiplomatWrite) -> Option<()>
pub fn script(&self, write: &mut DiplomatWrite) -> Option<()>
Returns a string representation of Locale script.
Sourcepub fn set_script(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
pub fn set_script(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
Set the script part of the Locale. Pass an empty string to remove the script.
Sourcepub fn normalize(
s: &DiplomatStr,
write: &mut DiplomatWrite,
) -> Result<(), LocaleParseError>
pub fn normalize( s: &DiplomatStr, write: &mut DiplomatWrite, ) -> Result<(), LocaleParseError>
Normalizes a locale string.
Sourcepub fn to_string(&self, write: &mut DiplomatWrite)
pub fn to_string(&self, write: &mut DiplomatWrite)
Returns a string representation of Locale.