deft.i18n

Localization seam.

Deft does not bundle a message-catalog parser — that would drag a dependency (and likely Phobos) into the library and force one catalog format on everyone. Instead it exposes a single pluggable hook: the application installs a Translator delegate with setTranslator, and every translatable string the framework emits is looked up through tr. The delegate is free to be backed by gettext, XLIFF, a plain associative array, or anything else — that choice (and any Phobos it needs) lives in the application, not here.

Without a translator installed, tr returns its argument unchanged, so an un-localized app behaves exactly as before. The framework's own handful of strings (the standard dialog buttons) additionally fall back to the operating system's localized text, so they are translated even with no catalog at all.

Install the translator once, before creating UI; reads are not synchronized.

Members

Aliases

Translator
alias Translator = string delegate(string key)

Looks up a translation for key, returning the translated string. A delegate may throw to signal "no translation"; callers fall back to key.

Functions

setTranslator
void setTranslator(Translator translator)

Install (or clear, with null) the application's translation delegate.

tr
string tr(string key)

Translate key through the installed Translator.

translator
Translator translator()

The currently installed translation delegate, or null.

Meta