Expand description
day-localization: the core localization engine (DESIGN.md §12), low enough in the crate graph that even the central crates (day-pieces’ dialogs, menu-role labels) can localize their own UI strings.
Two tiers of global Fluent bundles:
- core: a built-in catalog (
catalog/*.ftl) of the standard strings the framework itself emits (dialog OK/Cancel, standard menu commands), shipped in several languages. Always present. - app: the locales an app registers with
install. These take precedence over core, so an app can override anyday_*string, and core is the fallback for keys the app didn’t define.
Private Catalog namespaces live alongside these tiers. They share the locale signal,
but never merge their messages into app/core or each other.
The current locale is a Signal, so every format/binding re-runs on a locale switch. The
piece-facing reactive tr() wrapper lives one layer up in day-localization-ui (which re-exports this).
Modules§
- key
- The core catalog’s keys, one constant per message, named as the key itself
(
key::day_okis"day_ok"): what the framework’s own crates pass tot. Generated fromcatalog/en.ftlby this crate’s build script.
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.nameis only the qualified lookup name used by scripting (crate::file::key). - SigM
- ValM
Enums§
- Date
Fields - Which parts of an instant to write. The locale decides their order, words and punctuation.
- FArg
Traits§
- IntoF
Arg - Disjoint-marker conversion for
.argvalues (the same E0119 dodge asIntoText). - Into
NumberF Arg - Marker for
IntoFArgvalues that carry a number, required for a Fluent variable used as a plural /selectselector, where CLDR plural rules select on a number (so a string can’t be passed there by mistake). Implemented for the numericIntoFArgtypes only (i64,f64, and theirSignals); the generatedres::str::<key>(…)functions (§18.5) type such parameters asimpl IntoNumberFArginstead ofimpl 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_inin the current locale (tracked, likecrate::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 FluentDATETIME()builtin and of chart time axes) inlocale, showingfields(untracked). - format_
decimal - Render
vin the current locale (tracked, likecrate::compare), so a label inside a reactive closure re-renders when the locale switches. - format_
decimal_ in - Render
vinlocale, rounded tofraction_digitsand grouped by that locale’s own rule (untracked).1234.5is1,234.5inen,1 234,5infr,1.234,5inde. - 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-XAsuffix) resolves against the locale under the suffix and accents the result. Signal args are tracked reads. - format_
percent format_percent_inin the current locale (tracked), so a label inside a reactive closure re-renders when the locale switches.- format_
percent_ in - Render the fraction
vas a percentage inlocale(0.5is50%inen,50 %infr,%50intr), rounded tofraction_digitsplaces of the percentage and grouped by the locale’s rule (untracked). - install
- Register an app’s locales from
.ftlsources and set the current locale from (1) theDAY_LOCALElaunch override, (2) the platform’sset_launch_localehint, (3)default. Call once, before building the root piece. The built-in core catalog is preserved (and remains the fallback); the app’s strings take precedence over it, and re-registering reuses the existing localeSignalso bindings created earlier keep working. - locale
- The current locale (a tracked read inside bindings).
- matches_
search matches_search_inagainst the current locale. Reads the locale signal (tracked), so a filtered list inside a reactive closure re-filters when the language changes, the same contractcrate::comparehas.- matches_
search_ in - Whether
textmatchesqueryunderlocale’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
installruns. Platform glue only; apps pick locales withset_locale. No-op onceinstallhas resolved the initial locale. - set_
launch_ locales - Record the host’s ordered locale preference (
["fr-CA", "fr", "en"]) beforeinstallruns. - 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
keyin 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.