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.
translatefalls 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’st("key")returns. - try_
translate - Resolve
keyagainst the installed translator, orNonewhen no translator is installed or the catalogue lacks the key.
Type Aliases§
- Translator
- Resolves a translation key against the active catalogue. Returns
Nonewhen the catalogue has no entry for the key, so callers can apply their own fallback.