Expand description
This library provides a series of const lang-ids (language identifiers) which can be found in the
consts module. Additionally, it provides some handy maps.
§Examples
Using the result of a const fn as a value:
use lang_id::LangID;
// Compile-time verified language ID
const DEFAULT_LANG: LangID = lang_id::consts::lang_id_en();Description-data Lookup (requires map feature)
let map = lang_id::maps::description::map();
let gsw_fr = map.get("gsw-FR");
assert_eq!(gsw_fr, Some(&"Schwiizertüütsch, Latiinisch, Frankriich"));
let zh = map.get("zh");
assert_eq!(zh, Some(&"简体中文, 中国"));
let ja = map.get("ja");
assert_eq!(ja, Some(&"日本語, 日本語の文字, 日本"));§Features
| Feature | Dependencies | Description |
|---|---|---|
| std | None | Enables stdlib integrations |
| map | phf, tinystr | Adds precomputed static maps: - Perfect hash maps for O(1) lookups - Compact string storage with TinyStr |
| sys-locale | sys-locale, std | System locale detection: - Cross-platform locale querying - Integration with OS settings |
| match | None | Match the value or function name in consts using bytes, for example, b“en-001“ => lang_id_en_001(). |
| serde | unic-langid/serde | Serialization/deserialization support |
| consts | None | Provides const language ids |
Re-exports§
pub use error::LangidResult as Result;
Modules§
- common
- consts
consts - error
- maps
map - matches
match - nostd_
sys_ locale nostd-sys-locale - sys_
locale sys-locale - The sys-locale module is used to get the current system’s locale and convert it into LangID.