Internationalization
Display-text maps provide the English labels and format patterns used by library-generated documents.
Keys use domain.subdomain.name form and fall back to domain.name and then name.
Applications can clone the default map, edit the clone, and publish it through
Application::setDisplayTextMap().
A translator can replace resolved source text without changing map entries. Translation catalog and locale selection are intentionally left to translator implementations.
Interface
-
class DisplayTextMap
Central map for English system display texts and translated results.
Publish edited maps as
DisplayTextMapConstPtr. Concurrent const access is supported; concurrent mutation is not.Public Functions
-
DisplayTextMap()
Create a map populated with the built-in English display texts.
-
DisplayTextMapPtr clone() const
Clone source entries and the translator without copying caches.
-
text::String text(const text::String &key) const
Resolve and translate a display text.
Lookup order is the exact key,
domain.key, andkey. A missing entry returns the requested key.
-
text::StringFormat format(const text::String &key) const
Resolve, translate, and compile a reusable format.
-
DisplayTextMap &set(const text::String &key, text::String sourceText)
Set an English source text and clear all caches.
-
DisplayTextMap &remove(const text::String &key)
Remove a source text and clear all caches.
-
DisplayTextMap &setTranslator(DisplayTextTranslatorConstPtr translator)
Set the translator and clear all caches.
-
inline const DisplayTextTranslatorConstPtr &translator() const noexcept
Access the translator, if one is installed.
Public Static Functions
-
static const DisplayTextMapConstPtr &defaultMap()
Access the immutable process-wide English default map.
-
DisplayTextMap()
-
class DisplayTextTranslator
Translates one registered English display text.
Return an empty string to keep the English source text.
Public Functions
-
virtual text::String translate(const text::String &key, const text::String &sourceText) const = 0
Translate one display text.
- Parameters:
key – The originally requested display-text key.
sourceText – The resolved English source text.
- Returns:
The translated text, or an empty string to keep
sourceText.
-
virtual text::String translate(const text::String &key, const text::String &sourceText) const = 0