diff --git a/kaddressbookgrantlee/src/formatter/grantleecontactformatter.h b/kaddressbookgrantlee/src/formatter/grantleecontactformatter.h --- a/kaddressbookgrantlee/src/formatter/grantleecontactformatter.h +++ b/kaddressbookgrantlee/src/formatter/grantleecontactformatter.h @@ -61,6 +61,10 @@ Q_REQUIRED_RESULT QString toHtml(HtmlForm form = SelfcontainedForm) const override; void setShowQRCode(bool b); + + /** Translation domain for the Grantlee localizer. */ + void setApplicationDomain(const QByteArray &domain); + private: //@cond PRIVATE class Private; diff --git a/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp b/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp --- a/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp +++ b/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp @@ -26,8 +26,11 @@ #include "../contactobject/contactgrantleecryptoobject.h" #include + +#include +#include + #include -#include #include #include @@ -81,14 +84,13 @@ KConfigGroup group(&config, QStringLiteral("View")); showQRCode = group.readEntry("QRCodes", true); - mEngine = new Grantlee::Engine; + mEngine.reset(new GrantleeTheme::Engine); mTemplateLoader = QSharedPointer(new Grantlee::FileSystemTemplateLoader()); } ~Private() { - delete mEngine; mTemplateLoader.clear(); } @@ -109,7 +111,7 @@ } QVector mObjects; - Grantlee::Engine *mEngine = nullptr; + std::unique_ptr mEngine; QSharedPointer mTemplateLoader; Grantlee::Template mSelfcontainedTemplate; Grantlee::Template mEmbeddableTemplate; @@ -460,6 +462,7 @@ mapping.insert(QStringLiteral("colors"), colorsObject); Grantlee::Context context(mapping); + context.setLocalizer(d->mEngine->localizer()); if (form == SelfcontainedForm) { return d->mSelfcontainedTemplate->render(&context); @@ -469,3 +472,8 @@ return QString(); } } + +void GrantleeContactFormatter::setApplicationDomain(const QByteArray &domain) +{ + d->mEngine->localizer()->setApplicationDomain(domain); +}