Struct language_tag::tags::langtag::LangTag [] [src]

pub struct LangTag { /* fields omitted */ }

This stores a LangTag that define a language (with script, country, ...) according to BCP47 standard. You have probably already seen some. Examples: "en-US" (english as used in US), "fr-FR" (french as used in France), "zh-cmn-Hans-CN" (Chinese, Mandarin, Simplified script, as used in China) Two possibilities to create a LangTag: parse a string or use the builder.

Methods

impl LangTag
[src]

[src]

Get the TagLanguage containing the main language information and its extensions

Examples

use language_tag::tags::*;
use std::str::FromStr;

let langtag = LangTag::from_str("zh-cmn").unwrap();
let language = langtag.get_language();

assert_eq!(language.get_mainlang(), "zh");
assert_eq!(language.get_lang_extensions()[0], "cmn");

[src]

Get the TagScript containing the script information

Examples

use language_tag::tags::*;
use std::str::FromStr;

let langtag = LangTag::from_str("en-Latn-US").unwrap();
if let Some(ref script) = langtag.get_script() {
    assert_eq!(script.str(), "Latn");
}

[src]

Get the TagRegion containing the region information

Examples

use language_tag::tags::*;
use std::str::FromStr;

let langtag = LangTag::from_str("en-Latn-US").unwrap();
if let Some(ref region) = langtag.get_region() {
    assert_eq!(region.str(), "US");
}

[src]

[src]

[src]

Trait Implementations

impl Debug for LangTag
[src]

[src]

Formats the value using the given formatter.

impl Clone for LangTag
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for LangTag
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for LangTag
[src]

impl FromStr for LangTag
[src]

The associated error which can be returned from parsing.

[src]

Parses a string s to return a value of this type. Read more

impl Display for LangTag
[src]

[src]

Formats the value using the given formatter. Read more