# Language Tags
[](https://github.com/timothee-haudebourg/langtag/actions)
[](https://crates.io/crates/langtag)
[](https://github.com/timothee-haudebourg/langtag#license)
[](https://docs.rs/langtag)
This crate provides an implementation of *language tags* defined by
[RFC5646] ([BCP47]).
[RFC5646]: <https://tools.ietf.org/html/rfc5646>
[BCP47]: <https://tools.ietf.org/html/bcp47>
### Usage
You can easily parse new language from any string:
```rust
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.
You can use this library with `no_std` by disabling the `std` feature,
though it will also disable all the `*Buf` types.
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.