Skip to main content

Module i18n

Module i18n 

Source
Expand description

Process-wide translation hook - the one surface a script host reaches translation through.

Translation itself lives in lumen-i18n (Fluent bundles, locale fallback, ICU4X formatters), which core does not depend on: core carries no backend crates. What core owns is the seam. The runtime installs a translator with set_translator once it has loaded the app’s catalogues; every script host calls translate from its t() / tr() builtin without linking Fluent or reaching into the world.

This mirrors crate::nav: one process-global bus, many producers and consumers, no per-language plumbing. An app that never installs a translator still resolves every key - translate returns the key itself, which is exactly what an untranslated string should render as.

One translator is live at a time, so a host process running two Lumen apps shares the second app’s catalogue with the first. Markup translation avoids this by reading the per-app resource instead.

Functions§

clear_translator
Remove the installed translator. translate falls back to returning keys verbatim.
set_translator
Install the process-wide translator, replacing any previous one.
translate
Resolve key, falling back to the key itself. This is what a script’s t("key") returns.
try_translate
Resolve key against the installed translator, or None when no translator is installed or the catalogue lacks the key.

Type Aliases§

Translator
Resolves a translation key against the active catalogue. Returns None when the catalogue has no entry for the key, so callers can apply their own fallback.