pub struct Locale { /* private fields */ }Expand description
Re-export: size classes and orientation, so the application can drive its own
responsive behaviour.
A language, and optionally the script and the country it is written in
(locale.dart).
The language is required and the other two are not, which is the reference’s shape and
the useful one: fr is an answer, fr-CA is a better one, and zh-Hant-TW needs all
three to be right.
Comparison is exact — fr is not fr-CA. Deciding that one of them will do for the
other is resolve’s work, and it takes the whole list to do it.
Implementations§
Source§impl Locale
impl Locale
Sourcepub fn with_country(
language: impl Into<String>,
country: impl Into<String>,
) -> Locale
pub fn with_country( language: impl Into<String>, country: impl Into<String>, ) -> Locale
A language in a country: Locale::with_country("fr", "CA").
Sourcepub fn script(self, script: impl Into<String>) -> Locale
pub fn script(self, script: impl Into<String>) -> Locale
Adds a script (Hant, Latn): the writing system, which for some languages is
the question that decides legibility rather than idiom.
Sourcepub fn language_code(&self) -> &str
pub fn language_code(&self) -> &str
The language subtag, lowercase. Always present.
Sourcepub fn script_code(&self) -> Option<&str>
pub fn script_code(&self) -> Option<&str>
The script subtag, title case, if there is one.
Sourcepub fn country_code(&self) -> Option<&str>
pub fn country_code(&self) -> Option<&str>
The country subtag, uppercase, if there is one.
Sourcepub fn parse(tag: &str) -> Option<Locale>
pub fn parse(tag: &str) -> Option<Locale>
Reads a language tag: fr, fr-CA, fr_CA, zh-Hant-TW, en-US.UTF-8,
pt_BR@euro.
Both separators, because both arrive: a language tag uses - and a POSIX
environment variable uses _. The encoding and modifier suffixes a Unix LANG
carries are dropped — en_US.UTF-8 is the en-US locale in a particular byte
encoding, and the encoding is not part of which language this is.
A subtag is read by shape, as BCP 47 does: four letters is a script, two
letters or three digits is a region. That is what lets zh-Hant and zh-TW both
be understood without a table of every code.
Returns None for a tag with no language in it at all, including the C and
POSIX locales, which name an absence of one.
Trait Implementations§
impl Eq for Locale
Source§impl Ord for Locale
impl Ord for Locale
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Locale
impl PartialOrd for Locale
impl StructuralPartialEq for Locale
Auto Trait Implementations§
impl Freeze for Locale
impl RefUnwindSafe for Locale
impl Send for Locale
impl Sync for Locale
impl Unpin for Locale
impl UnsafeUnpin for Locale
impl UnwindSafe for Locale
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.