language-tags 0.0.1

Language tags for Rust
docs.rs failed to build language-tags-0.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: language-tags-0.3.2

rust-language-tags

Typesafe BCP47 language tag handling.

See also http://www.w3.org/International/articles/language-tags/

Features

  • Parsing and formatting tags ☑
  • Parts
  • Language ☑
  • Extlang ☑
  • Script ☑
  • Variant ☑
  • Region ☑
  • Extension ☐
  • Privateuse ☐
  • Comparing tags ☐
  • IANA registered tags ☐ (currently only example data)
  • Check if tag is valid ☐
  • much more... ☐

How to use it

Create tags:

use std::default::Default;
let mut tag: LanguageTag = Default::default();
tag.language = Some(Language::De);
tag.region = Some(Region::De);
println!("{}", tag) // "de-DE", German as spoken in Germany

Parse tags:

// Parse Arabic written in Latin script
let tag: LanguageTag = "ar-Latn".parse().unwrap();
println!("{}", tag.script.unwrap()); // "Latn"