oxilangtag

actions status Latest Version Released API docs

OxiLangTag is a Rust library allowing to validate and normalize language tags following RFC 5646 (BCP 47).

It is a fork of the language-tags focusing on RDF use cases. You might find the language-tags crate more convenient.

It allows zero stack allocation language tag validation. Getters are also provided to easily retrieve the various language tag components.

Example: ```rust use oxilangtag::LanguageTag;

// Parsing and validation let languagetag = LanguageTag::parse("zh-cmn-Hans-CN-x-test").unwrap(); asserteq!(languagetag.asstr(), "zh-cmn-Hans-CN-x-test");

// Language tag components asserteq!(languagetag.primarylanguage(), "zh"); asserteq!(languagetag.extendedlanguage(), Some("cmn")); asserteq!(languagetag.fulllanguage(), "zh-cmn"); asserteq!(languagetag.script(), Some("Hans")); asserteq!(languagetag.region(), Some("CN")); asserteq!(languagetag.extension(), None); asserteq!(languagetag.privateuse_subtags().collect::>(), vec!["test"]); ```

License

This project is licensed under the MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT).

It is based on the language-tags crate by pyfisch under MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Futures by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.