Skip to main content

Module strings

Module strings 

Source
Expand description

The words this library puts on screen, and the host’s right to replace them.

Components never hold English. They hold a StringKey, and ask the application context for the text behind it at render time, exactly the way they ask for a colour:

cx.strings().text(StringKey::Copy)

Every key carries an English default compiled into the binary, so a host that supplies nothing still gets a working, readable interface. A host that supplies some keys gets its own words for those and English for the rest; there is no state in which a label renders empty.

Strings with a value in them are templates over positional placeholders — {0}, {1} — rather than Rust format strings, because a translation is allowed to put the value somewhere else in the sentence:

cx.strings().format(StringKey::PaletteNoMatch, &[query])

§What is not here

Numbers, dates, and quantities are not translated. A count is still rendered with Rust’s own digits and a plural is still chosen by an if count == 1 at the call site, which is correct for English and for nothing else. docs/coverage.md records that as a named gap.

Structs§

Strings
The catalogue a host installs, and the one components read.

Enums§

StringKey
Every piece of text this library can put on a screen.

Traits§

ActiveStrings
Reads the installed catalogue from any context that dereferences to App, mirroring ActiveTheme.

Functions§

install
Installs the catalogue global. Idempotent, and never discards a catalogue a host already installed.
reset_strings
Restores the English for every entry and repaints every window.
set_strings
Replaces entries and repaints every window, the way activate_theme does.