10 releases (6 stable)

2.4.0 Nov 26, 2023
2.3.0 May 1, 2023
2.2.0 Nov 1, 2022
2.1.0 Dec 26, 2021
0.1.0 Apr 18, 2017

#25 in Internationalization (i18n)

Download history 1052/week @ 2023-12-25 1952/week @ 2024-01-01 2622/week @ 2024-01-08 2351/week @ 2024-01-15 2196/week @ 2024-01-22 2730/week @ 2024-01-29 2666/week @ 2024-02-05 2284/week @ 2024-02-12 2144/week @ 2024-02-19 2410/week @ 2024-02-26 2515/week @ 2024-03-04 3303/week @ 2024-03-11 3338/week @ 2024-03-18 2836/week @ 2024-03-25 3242/week @ 2024-04-01 1897/week @ 2024-04-08

11,594 downloads per month
Used in 37 crates (21 directly)


97K SLoC

ISO 639 language codes

Build Status Crates.io Documentation Licence: Apache 2.0


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 or autonyms (local names).

This crate contains the ISO 639 table in statically embedded tables. This increases binary size, but allows for very efficient look-up if performance matters. If size is a concern, both and the English names and local names can be enabled or disabled individually.

This crate is licensed under the Apache 2.0 license, please see LICENSE.md for the details.



isolang = "2.0"


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"));
// undefined language (ISO code und)
assert_eq!(Language::default(), Language::Und);
use isolang::Language;
// `to_name()` is available if compiled with the `english_names` feature.
assert_eq!(Language::from_str("es").unwrap().to_name(), "Spanish");
assert_eq!(Language::from_str("spa").unwrap().to_name(), "Spanish");
// `from_str(lowercase_name)` is available if compiled with the `english_names` and `lowercase_names` features.
assert_eq!(Language::from_str("spanish").unwrap().to_name(), "Spanish");
// `from_str(local_name)` is available if compiled with the `english_names`, `lowercase_names` and `local_names` features.
assert_eq!(Language::from_str("español").unwrap().to_name(), "Spanish");

Supported Cargo Features

Please take a look at the commented [Cargo.toml)(Cargo.toml) file for a up-to-date list of supported features.

Serde support

This crate also supports serializing the Language enum. To enable this please add the following lines to your Cargo.toml (instead of the above code):

features = ["serde"]
version = "2.0"

Data Source

The data is downloaded from https://iso639-3.sil.org/code_tables/download_tables.


~138K SLoC