language_tags::langtag!
[−]
[src]
macro_rules! langtag { ( $language:expr ) => { $crate::LanguageTag { language: Some(stringify!($language).to_owned()), extlangs: Vec::new(), script: None, region: None, variants: Vec::new(), extensions: ::std::collections::BTreeMap::new(), privateuse: Vec::new(), } }; ( $language:expr;;;$region:expr ) => { $crate::LanguageTag { language: Some(stringify!($language).to_owned()), extlangs: Vec::new(), script: None, region: Some(stringify!($region).to_owned()), variants: Vec::new(), extensions: ::std::collections::BTreeMap::new(), privateuse: Vec::new(), } }; ( $language:expr;;$script:expr ) => { $crate::LanguageTag { language: Some(stringify!($language).to_owned()), extlangs: Vec::new(), script: Some(stringify!($script).to_owned()), region: None, variants: Vec::new(), extensions: ::std::collections::BTreeMap::new(), privateuse: Vec::new(), } }; ( $language:expr;;$script:expr;$region:expr ) => { $crate::LanguageTag { language: Some(stringify!($language).to_owned()), extlangs: Vec::new(), script: Some(stringify!($script).to_owned()), region: Some(stringify!($region).to_owned()), variants: Vec::new(), extensions: ::std::collections::BTreeMap::new(), privateuse: Vec::new(), } }; ( $language:expr;$extlangs:expr) => { $crate::LanguageTag { language: Some(stringify!($language).to_owned()), extlangs: vec![stringify!($extlangs).to_owned()], script: None, region: None, variants: Vec::new(), extensions: ::std::collections::BTreeMap::new(), privateuse: Vec::new(), } }; ( $language:expr;$extlangs:expr;$script:expr) => { $crate::LanguageTag { language: Some(stringify!($language).to_owned()), extlangs: vec![stringify!($extlangs).to_owned()], script: Some(stringify!($script).to_owned()), region: None, variants: Vec::new(), extensions: ::std::collections::BTreeMap::new(), privateuse: Vec::new(), } }; ( $language:expr;$extlangs:expr;;$region:expr ) => { $crate::LanguageTag { language: Some(stringify!($language).to_owned()), extlangs: vec![stringify!($extlangs).to_owned()], script: None, region: Some(stringify!($region).to_owned()), variants: Vec::new(), extensions: ::std::collections::BTreeMap::new(), privateuse: Vec::new(), } }; ( $language:expr;$extlangs:expr;$script:expr;$region:expr ) => { $crate::LanguageTag { language: Some(stringify!($language).to_owned()), extlangs: vec![stringify!($extlangs).to_owned()], script: Some(stringify!($script).to_owned()), region: Some(stringify!($region).to_owned()), variants: Vec::new(), extensions: ::std::collections::BTreeMap::new(), privateuse: Vec::new(), } }; }
Utility for creating simple language tags.
The macro supports the language, exlang, script and region parts of language tags, they are separated by semicolons, omitted parts are denoted with mulitple semicolons.
Examples
it
:langtag!(it)
it-LY
:langtag!(it;;;LY)
it-Arab-LY
:langtag!(it;;Arab;LY)
ar-afb
:langtag!(ar;afb)
i-enochian
:langtag!(i-enochian)