diff --git a/src/libcalamares/locale/TranslatableConfiguration.cpp b/src/libcalamares/locale/TranslatableConfiguration.cpp index 1f0811c9d..c10307aee 100644 --- a/src/libcalamares/locale/TranslatableConfiguration.cpp +++ b/src/libcalamares/locale/TranslatableConfiguration.cpp @@ -23,9 +23,15 @@ namespace CalamaresUtils { namespace Locale { -TranslatedString::TranslatedString( const QString& string ) +TranslatedString::TranslatedString( const QString& key, const char* context ) + : m_context( context ) +{ + m_strings[ QString() ] = key; +} + +TranslatedString::TranslatedString( const QString& string ) + : TranslatedString( string, nullptr ) { - m_strings[ QString() ] = string; } TranslatedString::TranslatedString( const QVariantMap& map, const QString& key, const char* context ) diff --git a/src/libcalamares/locale/TranslatableConfiguration.h b/src/libcalamares/locale/TranslatableConfiguration.h index c45c8f523..04897c0a4 100644 --- a/src/libcalamares/locale/TranslatableConfiguration.h +++ b/src/libcalamares/locale/TranslatableConfiguration.h @@ -50,11 +50,23 @@ public: * metaObject()->className() as context (from a QObject based class) * to give the TranslatedString the same context as other calls * to tr() within that class. + * + * The @p context, if any, should point to static data; it is + * **not** owned by the TranslatedString. */ TranslatedString( const QVariantMap& map, const QString& key, const char* context = nullptr ); /** @brief Not-actually-translated string. */ TranslatedString( const QString& string ); + /** @brief Proxy for calling QObject::tr() + * + * This is like the two constructors above, with an empty map an a + * non-null context. It will end up calling tr() with that context. + * + * The @p context, if any, should point to static data; it is + * **not** owned by the TranslatedString. + */ + TranslatedString( const QString& key, const char* context ); /// @brief Empty string TranslatedString() : TranslatedString( QString() )