Expand description
Reactive localization that composes with existing text and string-taking APIs.
cranpose_ui::run_test_composition(|| {
let text = cranpose_ui::tr!("Hello, {name}!", name = "Ana");
assert!(text.as_str().contains("Ana"));
});Missing arguments are compile errors:
ⓘ
let _ = cranpose_ui::tr!("Hello, {name}!");Extra arguments are compile errors:
ⓘ
let _ = cranpose_ui::tr!("Save", unused = 42);Structs§
- Argument
- A named value passed to a message without allocating a string for numbers.
- Catalog
- Immutable, shareable parsed catalogs. Replacing a catalog replaces its cache identity.
- Deferred
Message - A message captured outside composition and translated when displayed.
Borrowed arguments become owned; cloning a request shares their storage.
Use
message!to construct one with checked source text and named arguments. - Language
- A supported application language and its native display name.
- Locale
- A validated language tag and optional localization preview.
- Locale
Formatters - Reusable ICU4X formatters bound to one explicit locale.
- Localization
- Shared application localization used by UI roots, workers, and native services. Each thread retains only its most recently used formatter. Language changes invalidate that formatter; repeated messages do not reconstruct Fluent bundles.
- Message
- A static message definition emitted by
tr!or generated catalog bindings. - Resource
- One embedded or application-loaded Fluent resource.
- Source
Catalog - Source-language messages shared by generated accessors and parsed on first use.
- Translator
- A thread-owned formatter with no cross-thread locks during formatting.
Construct one from a shared
Catalogon each thread that needs translations.
Enums§
- Fluent
Value - Values accepted by generated message accessors, including borrowed text and numbers.
The
FluentValueenum represents values which can be formatted to a String. - Format
Error - A locale formatting operation could not be completed.
- Language
Preference - A saved application language choice, independent of the current system locale.
- Localization
Error - A catalog, locale, or message could not be used.
- Preview
Mode - A visual stress test applied after message formatting.
Traits§
- Language
Preference Store - An application’s storage adapter for its language preference. Native UI providers call these methods on a worker so storage cannot block a frame.
Functions§
- Provide
Localization - Installs a catalog and language for this subtree, including its reading direction. Change the supplied locale state to update text and accessibility descriptions. Nested layout-direction providers can override the direction for individual controls.
- Provide
Translator - Installs a prepared translator, including one negotiated from several preferred languages.
- framework_
catalog - Translations for Cranpose controls, also usable by native services and test tools. UI providers add this fallback automatically; applications can override its namespaces. Translations for Cranpose controls, with namespaces applications can override.
- local_
formatters - Locale-aware data formatters retained for the current language provider. A language change replaces these formatters without changing stored application data.
- local_
translator - The translator installed by the nearest
ProvideLocalization.Noneuses each message’s inline source-language catalog. - localized
- Resolves a static message at this composition position. Prefer
crate::tr!. Unchanged arguments, catalog, and language reuse the previous formatted text. - localized_
message - Displays a message captured by
message!using the current provider. A language change updates the text even when the request remains in application state.
Type Aliases§
- Localized
Text - A formatted translation with shared text storage and owned-string conversions.