Skip to main content

Module localization

Module localization 

Source
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.
DeferredMessage
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.
LocaleFormatters
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.
SourceCatalog
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 Catalog on each thread that needs translations.

Enums§

FluentValue
Values accepted by generated message accessors, including borrowed text and numbers. The FluentValue enum represents values which can be formatted to a String.
FormatError
A locale formatting operation could not be completed.
LanguagePreference
A saved application language choice, independent of the current system locale.
LocalizationError
A catalog, locale, or message could not be used.
PreviewMode
A visual stress test applied after message formatting.

Traits§

LanguagePreferenceStore
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§

ProvideLocalization
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.
ProvideTranslator
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. None uses 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§

LocalizedText
A formatted translation with shared text storage and owned-string conversions.