About this project
Locale is a Rust workspace that provides strongly-typed locale identifiers generated from the Unicode CLDR (Common Locale Data Repository) dataset. The README states it covers 766 Unicode locales based on CLDR 48.1.0, with data sourced from the official CLDR-JSON repository.
The workspace contains two crates. locale-rs is the production library for locale management and formatting. locale-dev is a code generation tool that checks GitHub for the latest CLDR-JSON release, downloads or reuses cached data, regenerates locale-rs code, and then formats and lints the output. This design keeps the library in sync with new Unicode releases instead of relying on hardcoded strings.
Core capabilities described in the README include type-safe locales as compile-time validated enum variants, locale-aware number formatting using native digits, ICU-compatible currency patterns, and localized month and weekday names for datetime formatting. Parsing accepts hyphens, underscores, or mixed case. Locale negotiation finds the best match from available options using fallback chains, and fuzzy suggestions propose corrections for typos or unknown locales. The README also lists many supported digit systems, such as Latin, Arabic-Indic, Devanagari, Bengali, Tamil, Thai, and Tibetan.
Usage examples show direct enum access such as Locale::en_GB, parsing via FromStr or from_flexible, extracting language and region subtags, and obtaining a fallback locale. Number formatting is demonstrated through a ToFormattedString trait, producing grouped output such as 1,234,567 for English and 1.234.567 for German. Negotiation and suggestion examples are also provided.
The README claims zero-cost abstractions and zero-sized locale enum variants. It notes architectural inspiration from the num-format crate. Licensing is dual MIT or Apache-2.0 for the project code, while locale data derives from Unicode CLDR under the Unicode License V3. Contributions are directed mainly at the generation logic in locale-dev or at helper methods, tests, and examples in locale-rs.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.