[libcalamares] Document how TranslatedString context works

- Support re-using class-specific tr() calls in a standard way
- Document this in the netinstall.conf which uses it
This commit is contained in:
Adriaan de Groot 2020-02-19 14:23:34 +01:00
parent a03394f177
commit 81752b6f7c
2 changed files with 20 additions and 3 deletions

View File

@ -39,6 +39,17 @@ class DLLEXPORT TranslatedString
{ {
public: public:
/** @brief Get all the translations connected to @p key /** @brief Get all the translations connected to @p key
*
* Gets map[key] as the "untranslated" form, and then all the
* keys of the form <key>[lang] are taken as the translation
* for <lang> of the untranslated form.
*
* If @p context is not a nullptr, then that is taken as an
* indication to **also** use the regular QObject::tr() translation
* mechanism for these strings. It is recommended to pass in
* metaObject()->className() as context (from a QObject based class)
* to give the TranslatedString the same context as other calls
* to tr() within that class.
*/ */
TranslatedString( const QVariantMap& map, const QString& key, const char* context = nullptr ); TranslatedString( const QVariantMap& map, const QString& key, const char* context = nullptr );
/** @brief Not-actually-translated string. /** @brief Not-actually-translated string.

View File

@ -30,8 +30,14 @@ required: false
# If no *sidebar* values are provided, defaults to "Package selection" # If no *sidebar* values are provided, defaults to "Package selection"
# and existing translations. If no *title* values are provided, no string # and existing translations. If no *title* values are provided, no string
# is displayed. # is displayed.
#
# The following strings are already known to Calamares and can be
# listed here in *untranslated* form (e.g. as value of *sidebar*)
# without bothering with the translations: they are picked up from
# the regular translation framework:
# - "Package selection"
label: label:
sidebar: "Package selection" sidebar: "Package selection"
sidebar[nl]: "Pakketkeuze" # sidebar[nl]: "Pakketkeuze"
title: "Office Package" # title: "Office Package"
title[nl]: "Kantoorsoftware" # title[nl]: "Kantoorsoftware"