Crates.io | language-enum |
lib.rs | language-enum |
version | 0.1.0 |
source | src |
created_at | 2024-09-08 18:59:15.857032 |
updated_at | 2024-09-08 18:59:15.857032 |
description | A robust enum representing languages for global and regional applications. |
homepage | |
repository | https://github.com/klebs6/klebs-general |
max_upload_size | |
id | 1368462 |
size | 13,928 |
language-enum
is a robust, exhaustive enum representing a wide variety of global and regional languages. It’s designed for use in applications that require internationalization (i18n), localization, and handling of multiple languages.
serde
to easily serialize and deserialize languages.Other
Variant: Allows specifying languages not covered in the predefined enum through the Other(String)
variant.serde
support, the crate is dependency-free.Add language-enum
to your Cargo.toml
:
[dependencies]
language-enum = "0.1"
To enable serde support for serialization and deserialization:
[dependencies]
language-enum = { version = "0.1", features = ["serde"] }
use language_enum::Language;
fn main() {
let lang = Language::English;
println!("Selected language: {:?}", lang);
// Using the `Other` variant for an unsupported language
let other_lang = Language::Other("Klingon".to_string());
println!("Other language: {:?}", other_lang);
}
The Language enum includes a wide range of languages such as:
Major Languages: English, Spanish, Chinese (Mandarin), Arabic, Russian, etc. Regional Languages: Breton, Hawaiian, Basque, and others. Indigenous Languages: Cherokee, Navajo, Maori, and more. It also includes an Other(String) variant to cover any languages not explicitly listed.
Serialization: Serialize and deserialize the enum with serde. Exhaustive: Covers a broad range of languages for various applications. Custom Language Support: Use Language::Other(String) for languages not in the predefined set. License
Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.
Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.