Skip to main content

Module translate

Module translate 

Source
Expand description

Resolving the strings an element shows into one language.

translatable="key" names one catalogue message, and the element’s every visible string comes off it: the text from the message value, and each further string from the Fluent attribute of the same name. So a search box written as

<input placeholder="Search catalogue" translatable="search"/>

reads its placeholder from search.placeholder, and an author names one key per widget rather than one per string.

This lives here, below both consumers, because the desktop spawner and the web emitter resolve the same element and must reach the same strings: an app run in a locale and a page built for it read alike. The rule has to know which attributes the markup authored, which the catalogue cannot see, so it belongs on this side of the seam. lumen-ir itself stays free of a translation dependency: the caller brings the lookup.

The rule’s input is AuthoredStrings, which is what the markup wrote. A spawned element keeps that component, so the same rule resolves it again when the app changes locale while it runs, reaching the strings the catalogue holds now rather than the ones on screen.

Structs§

TranslatedStrings
What an element shows once its catalogue key has been resolved.

Functions§

attribute_key
The catalogue key the name string of a translatable="key" element resolves through.
translate
Every string authored shows, resolved through lookup.