From 81752b6f7c927b902a76d791c3e179320dd31492 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 19 Feb 2020 14:23:34 +0100 Subject: [PATCH] [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 --- src/libcalamares/locale/TranslatableConfiguration.h | 11 +++++++++++ src/modules/netinstall/netinstall.conf | 12 +++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/libcalamares/locale/TranslatableConfiguration.h b/src/libcalamares/locale/TranslatableConfiguration.h index f1abb51ff..d845569bc 100644 --- a/src/libcalamares/locale/TranslatableConfiguration.h +++ b/src/libcalamares/locale/TranslatableConfiguration.h @@ -39,6 +39,17 @@ class DLLEXPORT TranslatedString { public: /** @brief Get all the translations connected to @p key + * + * Gets map[key] as the "untranslated" form, and then all the + * keys of the form [lang] are taken as the translation + * for 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 ); /** @brief Not-actually-translated string. diff --git a/src/modules/netinstall/netinstall.conf b/src/modules/netinstall/netinstall.conf index ab600326e..188642683 100644 --- a/src/modules/netinstall/netinstall.conf +++ b/src/modules/netinstall/netinstall.conf @@ -30,8 +30,14 @@ required: false # If no *sidebar* values are provided, defaults to "Package selection" # and existing translations. If no *title* values are provided, no string # 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: sidebar: "Package selection" - sidebar[nl]: "Pakketkeuze" - title: "Office Package" - title[nl]: "Kantoorsoftware" + # sidebar[nl]: "Pakketkeuze" + # title: "Office Package" + # title[nl]: "Kantoorsoftware"