ISO 639 language codes
Introduction
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.
This crate contains the ISO 639 table in statically embedded tables. This is possibly large, but can outweight the benefits, when handling different language code formats, e.g. when handling API data from Wikipedia and FreeDict.
Conditional compilation to reduce code size is not supported at the moment.
This crate is licensed under the Apache 2.0 license, please see LICENSE.md for the details.
Usage
Cargo.toml
:
[]
= "1.0"
Example
use Language;
assert_eq!;
assert_eq!;
// undefined language (ISO code und)
assert_eq!;
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):
[]
= ["serde_serialize"]
= "1.0"
Diesel support
This crate also has experimental support for diesel. You can use the Language
enum in Queryable
and Insertable
structs. To enable this please add the
following lines to your Cargo.toml
.
[]
= ["diesel_sql"]
= "1.0"