A rust crate providing ISO 639 1, ISO 639 2, ISO 639 3 , ISO 15924 support.
ISO 639 is a standardized nomenclature used to classify languages. Each language is assigned a two-letter (639-1) and three-letter (639-2 and 639-3) lowercase abbreviation, amended in later versions of the nomenclature.
This table lists all of:
ISO 639-1: two-letter codes, one per language for ISO 639 macrolanguage And some of:
ISO 639-2/T: three-letter codes, for the same languages as 639-1
ISO 639-2/B: three-letter codes, mostly the same as 639-2/T, but with some codes derived from English names rather than native names of languages (in the following table, these differing codes are highlighted in boldface)
ISO 639-3: three-letter codes, the same as 639-2/T for languages, but with distinct codes for each variety of an ISO 639 macrolanguage
ISO 15924, Codes for the representation of names of scripts, is an international standard defining codes for writing systems or scripts (a "set of graphic characters used for the written form of one or more languages"). Each script is given both a four-letter code and a numeric code.[1]
Where possible the codes are derived from ISO 639-2, where the name of a script and the name of a language using the script are identical (example: Gujarātī ISO 639 guj, ISO 15924 Gujr). Preference is given to the 639-2 Bibliographical codes, which is different from the otherwise often preferred use of the Terminological codes.[1]
4-letter ISO 15924 codes are incorporated into the IANA Language Subtag Registry for IETF language tags and so can be used in file formats that make use of such language tags. For example, they can be used in HTML and XML to help Web browsers determine which typeface to use for foreign text. This way one could differentiate, for example, between Serbian written in the Cyrillic (sr-Cyrl) or Latin (sr-Latn) script, or mark romanized or transliterated text as such.
-- Wikipedia
sh
[dependencies]
rust_iso639 = "0.0.1"
rust-iso/rust_iso39 is licensed under the Apache-2.0 license.
See using section of the documentation.
Quick guide:
```rust let lang = rustiso639::fromcode1("zh"); let lang = rustiso639::fromcode2t("zho"); let lang = rustiso639::fromcode2b("chi"); let lang = rustiso639::fromcode3("zho");
println!("{:?}", rustiso639::ALL); println!("{:?}", rustiso639::ALL1); println!("{:?}", rustiso639::ALL2B); println!("{:?}", rustiso639::ALL2T); println!("{:?}", rustiso639::ALL_3);
println!("{:?}", rustiso639::ALLMAP); println!("{:?}", rustiso639::ALL1MAP); println!("{:?}", rustiso639::ALL2BMAP); println!("{:?}", rustiso639::ALL2TMAP); println!("{:?}", rustiso639::ALL3MAP); ```
Data sample:
```rust pub struct LanguageCode<'a> { ///ISO Language Name pub name: &'static str, ///639-1 pub code: &'static str, ///639-2/T pub code2t: &'static str, ///639-2/B pub code2b: &'static str, //639-3 Macrolanguage pub code_3: &'static str,
pub individual_languages: &'a [IndividualLanguages],
}
pub struct IndividualLanguages { ///Name pub name: &'static str, ///Code pub code: &'static str, } ```