Crate isolang

source ·
Expand description

ISO 639 language codes

When dealing with different language inputs and APIs, different standards are used to identify a language. Converting between these in an automated way can be tedious. This crate provides an enum which supports conversion from 639-1 and 639-3 and also into these formats, as well as into English names.

The language table is compiled into the library. While this increases the binary size, it means that no additional time is wasted on program startup or on table access for allocating or filling the map. It is hence suitable for retrieval of codes in constraint environments.

Examples

use isolang::Language;

assert_eq!(Language::from_639_1("de").unwrap().to_name(), "German");
assert_eq!(Language::from_639_3("spa").unwrap().to_639_1(), Some("es"));

Enums