|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
The renderer-side translation-catalog seam over morph's derived message keys (morph::forms::i18n, forms/i18n.hpp). More...
#include <functional>#include <optional>#include <string>#include <string_view>Go to the source code of this file.
Typedefs | |
| using | morph::render::TranslationProvider |
| A host-supplied catalog lookup: key/bcp47Locale -> translated text, or std::nullopt on a miss. | |
Functions | |
| std::string | morph::render::resolveText (const TranslationProvider &provider, std::string_view bcp47Locale, const std::optional< std::string > &explicitKey, std::string_view derivedKey, std::string_view schemaLiteral) |
| Resolves one display slot's text: explicit key, then derived key, then the schema literal. | |
The renderer-side translation-catalog seam over morph's derived message keys (morph::forms::i18n, forms/i18n.hpp).
morph::render is client-side only and never appears on the wire — it is the C++ side of the client-side rendering seam. morph ships this seam and the resolution algorithm below; it defines no translation storage format. A host adapts whatever catalog it already owns (Qt QTranslator/.qm, a JSON bundle, a database) into the one TranslationProvider signature.
Definition in file i18n.hpp.
A host-supplied catalog lookup: key/bcp47Locale -> translated text, or std::nullopt on a miss.
A default-constructed (empty) TranslationProvider means "no catalog installed" — resolveText treats it the same as a provider that misses on every key.
|
inlinenodiscard |
Resolves one display slot's text: explicit key, then derived key, then the schema literal.
Tried in order, most specific first:
explicitKey (a host-declared x-i18nKey-derived key), if present;derivedKey (morph::forms::i18n::fieldKey or one of its siblings);schemaLiteral — the schema's authored title / description / x-placeholder / group or step title, unchanged. An empty/unset provider ("no catalog installed") skips straight to schemaLiteral, matching an unconfigured renderer's behavior exactly. | provider | The host's catalog lookup. |
| bcp47Locale | The locale to resolve against (e.g. "fr-FR"). |
| explicitKey | The field/group/rule/step's declared x-i18nKey-based key, or std::nullopt when none is declared. |
| derivedKey | The mechanically-derived key for this slot. |
| schemaLiteral | The schema's authored fallback text for this slot. |