[libcalamares] Extend (configuration) translated string with context

Make it possible to pass in a context for strings not-from-config
maps, to allow programmatically set, but translatable, strings.
main
Adriaan de Groot 4 years ago
parent 35f4a81768
commit ed14c49a03

@ -23,9 +23,15 @@ namespace CalamaresUtils
{
namespace Locale
{
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 )

@ -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() )

Loading…
Cancel
Save