|
| std::optional< std::string > | morph::ui::catalogueLocale (std::string_view fileId) |
| | Reads the locale from a catalogue's id.
|
| std::expected< Catalogue, std::string > | morph::ui::parseCatalogue (std::string_view text) |
| | Parses a catalogue: a flat JSON object of message key to MessageFormat 2 pattern.
|
| MessageCatalogues | morph::ui::loadCatalogues (Manifest const &manifest, std::map< std::string, std::string, std::less<> > const &files) |
| | Reads every message catalogue a verified bundle lists.
|
| std::vector< std::string > | morph::ui::textInEveryLocale (MessageCatalogues const &catalogues, std::string_view key, std::string_view fallback) |
| | A message formatted in every locale the catalogues hold: what a search over titles compares against.
|
| bool | morph::ui::matchesInAnyLocale (MessageCatalogues const &catalogues, std::string_view key, std::string_view fallback, std::string_view query) |
| | Whether a message contains query in any locale the catalogues hold, or in its fallback: a navigator's search, so a user finds a screen by the title they know in any language.
|
| TitleParts | morph::ui::detail::catalogue::titleParts (Json const &title) |
| | Splits a catalog title into its parts.
|
| std::optional< std::string > | morph::ui::detail::catalogue::formatPattern (std::string_view pattern, std::string const &locale) |
| | A message pattern formatted with no arguments.
|
| std::string | morph::ui::catalogTitle (CatalogEntry const &entry, MessageCatalogues const *catalogues, std::string_view locale) |
| | A catalog entry's title in one locale, as a shell's tab or header shows it.
|
| std::vector< std::string > | morph::ui::catalogTitles (CatalogEntry const &entry, MessageCatalogues const *catalogues) |
| | A catalog entry's title in every locale the catalogues hold: what a search over screen titles compares against.
|
Message catalogues (spec 6 §19): a bundle's messages files read into a TranslationProvider that t resolves through, and the search that matches a title in every locale the bundle has.
Specified in docs/spec/ui/catalogue.md.
Definition in file catalogue.hpp.
| std::expected< Catalogue, std::string > morph::ui::parseCatalogue |
( |
std::string_view | text | ) |
|
|
inlinenodiscard |
Parses a catalogue: a flat JSON object of message key to MessageFormat 2 pattern.
Refused: text that is not JSON or nests deeper than kMaxJsonDepth, anything but an object, a must-understand (!) key, a value that is not a string, an empty key or one longer than kMaxNameBytes, and more than kMaxCatalogueKeys keys. A pattern outside the ui/1 subset does not refuse the catalogue: its key is left out and listed in dropped, so t shows the fallback for it.
- Parameters
-
| text | The catalogue's JSON text. |
- Returns
- The catalogue, or the reason it is refused.
Definition at line 74 of file catalogue.hpp.
| MessageCatalogues morph::ui::loadCatalogues |
( |
Manifest const & | manifest, |
|
|
std::map< std::string, std::string, std::less<> > const & | files ) |
|
inlinenodiscard |
Reads every message catalogue a verified bundle lists.
A catalogue whose id is not i18n/LOCALE.json, whose bytes are not among files, or that parseCatalogue refuses, is left out, and its locale shows the fallbacks; a pattern outside the subset is dropped. Each is noted in problems(). Nothing is refused later, at a t.
- Parameters
-
| manifest | The bundle's manifest (LoadedBundle::manifest). |
| files | The verified files by content hash (LoadedBundle::files). |
- Returns
- The catalogues.
Definition at line 188 of file catalogue.hpp.
A catalog entry's title in one locale, as a shell's tab or header shows it.
A string title is shown as is. A message reference ({"t": key, "fallback": …}) is formatted in locale from catalogues — the exact locale's catalogue, then its language's — and is its fallback when no catalogue has the key. A title that is neither, or a reference with no fallback that no catalogue resolves, is the entry's id.
- Parameters
-
| entry | The entry. |
| catalogues | The message catalogues, or null for none. |
| locale | The BCP 47 locale to format in. |
- Returns
- The title.
Definition at line 337 of file catalogue.hpp.
A catalog entry's title in every locale the catalogues hold: what a search over screen titles compares against.
With catalogues, a message reference is textInEveryLocale of its key and fallback (the entry's id when it has none). Without, the one title is a string title as is, else a reference's fallback, else the entry's id.
- Parameters
-
| entry | The entry. |
| catalogues | The message catalogues, or null for none. |
- Returns
- The titles; never empty.
Definition at line 365 of file catalogue.hpp.