pub struct LangCode(/* private fields */);Expand description
A language’s tag, the name of its folder among the languages: BCP 47
(RFC 5646) in this subset, its subtags joined by -:
- the language: 2 to 8 letters (
en,ja); - a script, if any: 4 letters (
zh-Hans); - a region, if any: 2 letters or 3 digits (
pt-BR,es-419); - variants, each once: 5 to 8 letters or digits, or a digit and 3
letters or digits (
de-CH-1996); - a private-use part, if any:
xand one or more subtags of 1 to 8 letters or digits (en-x-pseudo).
At most 35 characters in all. A tag has one spelling: the language,
variants and private use in lower case, the script in title case and the
region in upper case. A tag compares, orders and hashes as its text, so
a map keyed by tags is looked up by &str too.
Implementations§
Source§impl LangCode
impl LangCode
Sourcepub fn new(text: &str) -> Option<Self>
pub fn new(text: &str) -> Option<Self>
text as a tag, if it is one written as a tag is written (pt-BR,
not pt_br); None otherwise. For text from outside, use
parse.
Sourcepub fn parse(text: &str) -> Result<Self, TagError>
pub fn parse(text: &str) -> Result<Self, TagError>
The tag text names, written as a tag is written: any case, _ for
-, and a POSIX locale’s .charset and @modifier left out
(pt_BR.UTF-8 is pt-BR). For the system’s languages and the
command line. Fails with what is wrong.
Sourcepub fn english() -> Self
👎Deprecated: a game’s source language is Lang::source_lang()
pub fn english() -> Self
a game’s source language is Lang::source_lang()
English, the source language when a game declares none.