Skip to main content

Crate day_localization_ui

Crate day_localization_ui 

Source
Expand description

day-localization-ui: the piece-facing localization layer over the day_localization engine (DESIGN.md §12).

The engine (bundles, the current-locale signal, format_in, and the built-in core catalog of standard UI strings) now lives in day-localization, low enough that the central crates localize their own strings. This crate re-exports that engine and adds the reactive tr() text source: label(tr("greeting").arg("name", name)), whose value re-reads the locale signal plus any signal args, so a locale switch updates every visible string fine-grained, followed by one relayout.

Modules§

key
The core catalog’s keys, one constant per message, named as the key itself (key::day_ok is "day_ok"): what the framework’s own crates pass to t. Generated from catalog/en.ftl by this crate’s build script.
res
Day’s own strings, named the way an app’s are: res::str::day_cancel(), res::str::day_about_app(name), one typed function per message in the core catalog (day-localization/catalog/en.ftl), generated from it at build time (docs/localization.md).

Macros§

locales
Include the private localization modules written by day_build::generate_locales(). Usable by reusable pieces without depending on the day umbrella crate.

Structs§

Catalog
An embedded, private Fluent namespace. Generated by day_build::generate_locales. Catalog identity is its static address, so identical keys in different crates never collide. name is only the qualified lookup name used by scripting (crate::file::key).
LocalizedMark
LocalizedText
A localized text source: label(tr("greeting").arg("name", name)) (§12.2).
SigM
ValM

Enums§

DateFields
Which parts of an instant to write. The locale decides their order, words and punctuation.
FArg

Traits§

IntoFArg
Disjoint-marker conversion for .arg values (the same E0119 dodge as IntoText).
IntoNumberFArg
Marker for IntoFArg values that carry a number, required for a Fluent variable used as a plural / select selector, where CLDR plural rules select on a number (so a string can’t be passed there by mistake). Implemented for the numeric IntoFArg types only (i64, f64, and their Signals); the generated res::str::<key>(…) functions (§18.5) type such parameters as impl IntoNumberFArg instead of impl IntoFArg.

Functions§

add_launch_locales
Append the host’s ordered preference after anything already recorded.
compare
Compare two strings in the current locale’s collation order. Reads the locale signal (tracked), so a sort inside a reactive closure re-runs when the locale switches.
compare_in
Compare two strings in locale’s collation order (untracked; accepts -u-co- extensions, e.g. "zh-u-co-stroke"). Falls back to code-point order if the locale has no collation data.
format_catalog
Format within one private namespace; missing keys fall back only to this catalog’s default. App/core catalogs cannot accidentally supply a similarly named key from another component.
format_date
format_date_in in the current locale (tracked, like crate::format_decimal), so a label inside a reactive closure re-renders when the locale switches.
format_date_in
Write the instant epoch_seconds (seconds since 1970-01-01T00:00:00Z, read as UTC civil time, the convention of the Fluent DATETIME() builtin and of chart time axes) in locale, showing fields (untracked).
format_decimal
Render v in the current locale (tracked, like crate::compare), so a label inside a reactive closure re-renders when the locale switches.
format_decimal_in
Render v in locale, rounded to fraction_digits and grouped by that locale’s own rule (untracked). 1234.5 is 1,234.5 in en, 1 234,5 in fr, 1.234,5 in de.
format_in
Resolve key: app bundle for the locale, then app-default, then the built-in core catalog for the locale, then core English. A pseudo-locale (en-XA, fr-XA: any locale with the -XA suffix) resolves against the locale under the suffix and accents the result. Signal args are tracked reads.
format_percent
format_percent_in in the current locale (tracked), so a label inside a reactive closure re-renders when the locale switches.
format_percent_in
Render the fraction v as a percentage in locale (0.5 is 50% in en, 50 % in fr, %50 in tr), rounded to fraction_digits places of the percentage and grouped by the locale’s rule (untracked).
install
Register the app’s locales (see day_localization::install) and fix the layout direction from the locale that actually resolved (docs/localization): an RTL locale (Arabic, Hebrew, …) mirrors every horizontal placement and flips the native toolkit’s direction. Direction is resolved once, before the first layout; runtime set_locale switches strings but not direction.
locale
The current locale (a tracked read inside bindings).
matches_search
matches_search_in against the current locale. Reads the locale signal (tracked), so a filtered list inside a reactive closure re-filters when the language changes, the same contract crate::compare has.
matches_search_in
Whether text matches query under locale’s rules (untracked: pass the locale explicitly).
register_catalog
Make a catalog available for qualified scripting lookups. Generated accessors call this automatically. Registration never changes the app locale or its default catalog.
set_launch_locale
Record the host’s launch locale before install runs. Platform glue only; apps pick locales with set_locale. No-op once install has resolved the initial locale.
set_launch_locales
Record the host’s ordered locale preference (["fr-CA", "fr", "en"]) before install runs.
set_locale
Switch the locale at runtime; every tr/binding re-runs.
sort_localized
Sort a slice in place in the current locale’s collation order (tracked, like compare).
strip_isolates
Strip Fluent’s FSI/PDI isolation marks (dayscript text comparison, §14.3).
t
Resolve key in the current locale (no args): the one-shot form the framework’s own strings use (dialog buttons, menu-role labels), which are resolved once at present/build time. The key is always a generated name, t(key::day_cancel), never a string literal.
tr
tr_in
Bind a key to a private crate/file catalog. Prefer generated typed accessors.