Expand description
§WaterUI i18n
Internationalization (i18n) support for WaterUI applications.
§What it does
Always available:
- Type-safe locales: Using ICU4X for locale identifiers
- CLDR plural rules: Proper pluralization for all languages
- Smart fallback: zh-TW → zh-Hant → zh (not zh-Hans!)
LocalizedDisplay: Trait for locale-aware formatting
Behind a cargo feature, because each carries its own slice of CLDR data:
number:format_number,format_percent,format_currency, the unit wrappers (Length<Meter>,Temperature<Celsius>, …) that render through them, and the numeric interpolationtext!performsdatetime:format::date, the locale-aware date and time formatterslist:LocalizedList, locale-aware list conjunction
§Usage
Application text goes through waterui’s text! macro, which resolves
translations and CLDR plural categories against the effective locale:
use waterui::prelude::*;
// With en: "I have 5 apples"
// With zh: "我有5个苹果"
text!("I have {#count} apple")This crate is the runtime underneath it: locale identification and fallback, plural-category selection, and locale-aware formatting.
use waterui_locale::{PluralCategory, locales, select_plural};
assert_eq!(select_plural(&locales::EN, &1), PluralCategory::One);
assert_eq!(select_plural(&locales::EN, &5), PluralCategory::Other);Re-exports§
pub use catalog::TranslationCatalog;pub use format::LocalizedDisplay;pub use locale::Locale;pub use locale::locales;pub use plural::select_plural;pub use plural::valid_categories;
Modules§
- catalog
- Runtime translation catalog loaded from app-provided i18n tables.
- format
- Locale-aware formatting utilities.
- locale
- Locale types and constants using ICU4X.
- parser
- TOML translation file parser.
- plural
- CLDR plural rules using ICU4X.
- regional
- Shared locale runtime for
WaterUI.
Enums§
- Plural
Category - Re-export
PluralCategoryfrom ICU4X. The plural categories are used to format messages with numeric placeholders, expressed as decimal numbers.
Functions§
- layout_
direction - Returns the Unicode layout direction for a locale.
- layout_
direction_ computed - Returns a reactive layout direction derived from the effective locale.
- locale_
binding - Returns a reactive binding for the effective locale in the given environment.
- start_
system_ locale_ listener - Starts delivering system locale changes to locale-aware views.