Expand description
This crate provides an implementation of language tags defined by RFC5646 (BCP47).
§Usage
You can easily parse new language from any string:
use langtag::LangTag;
fn main() -> Result<(), langtag::InvalidLangTag<&'static str>> {
let tag = LangTag::new("fr-FR")?;
assert_eq!(tag.language().unwrap().primary(), "fr");
assert!(tag == "Fr-fr"); // comparison is case-insensitive.
Ok(())
}
Note that LangTag::new
does not copy the data it is given,
but only borrows it. The LangTagBuf
type allows you to own the language
tag. Once parsed, you can explore every component of the language tag using
the provided functions.
Structs§
- Single extended language subtag.
- Owned ExtendedLangTag.
- Single extension and its subtags.
- Owned extension.
- Single extension subtag.
- Owned ExtensionSubtag.
- List of extensions.
- Owned Extensions.
- Any language tag (normal, private use or grandfathered).
- Owned LangTag.
- Primary and extended language subtags.
- Owned language.
- List of extended language subtags.
- Owned extlang.
- Normal language tag.
- Owned langtag.
- Primary language subtag.
- Owned extlang.
- Private use.
- Owned privateuse.
- Private use subtag.
- Owned PrivateUseSubtag.
- Region subtag.
- Owned region.
- Script subtag.
- Owned script.
- Extension identifier.
- Single variant subtag.
- Owned variant.
- List of variant subtags.
- Owned Variants.
Enums§
- Grandfathered tags.
- Language tag kind (normal, private use or grandfathered).
- Language tag with type information (normal, private use or grandfathered).
Statics§
- List of all grandfathered tags.
Type Aliases§
- Private use language tag.
- Owned private use language tag.