acron.strings

A string table with locales: every word an interface shows, by a stable key, with a translation merged over it.

The mechanism a localised game needs and RmlUi does not give: a reference table ({key: text}, the writing’s own language), a locale file of the same keys in another language merged over it (a key the locale lacks falls back to the reference), the check that tells a translator what is missing and what went stale, and the export a translation starts from. The keys, the texts and where the documents get filled are the game’s.

  • StringTable holds the reference and the active table: tr() formats a key’s text with its fields; rml() escapes it for RmlUi unless the key is in the markup set (a bold, a line break authored on purpose); fill() writes keys into a document’s static elements (an element the document lacks is skipped — a proof of concept’s document still loads); load_locale() merges a file over the reference, or resets to it.

  • read_locale() reads one locale file defensively — only its string entries, so a malformed file cannot put a number on screen — and available() lists the languages a directory holds.

  • check() compares a locale against a reference: the keys it is missing, and the keys it carries that the reference no longer has (stale — the text moved, so a derived id changed).

StringTable(reference, *[, markup, locale_dir])

A reference table and the locale merged over it.

Global Functions

available(directory) → list[str]

The languages with a <lang>.json under directory.

check(reference: dict[str, str], locale: dict[str, str]) → tuple[list[str], list[str]]

A locale against a reference: the keys it is missing (of those the reference has text for), and the keys it carries that the reference lacks (stale).

read_locale(path) → dict[str, str] | None

One locale file as {key: text} — its string entries only. None if there is no such file or it does not parse to an object.