diff options
| author | Andrew Branson <andrew.branson@jolla.com> | 2026-03-09 09:44:01 +0100 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@jolla.com> | 2026-03-09 21:13:03 +0100 |
| commit | e93766b063432347bd1062aa59bbe122ee7a43f3 (patch) | |
| tree | 4b2f66a383400e8428f6c6388084685a915b2902 /buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationsplugin.cpp | |
| parent | 9182ffb1573c77367ad6b5e4b1f3e4f52b3c3ea4 (diff) | |
Localize settings text and refresh Mastodon docsrefactor
- Add QTranslator to notifications plugin
- Create own logging category now trace is gone
Diffstat (limited to 'buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationsplugin.cpp')
| -rw-r--r-- | buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationsplugin.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationsplugin.cpp b/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationsplugin.cpp index fe9f989..9dd3724 100644 --- a/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationsplugin.cpp +++ b/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationsplugin.cpp @@ -22,6 +22,52 @@ #include "mastodonnotificationssyncadaptor.h" #include "socialnetworksyncadaptor.h" +#include <QCoreApplication> +#include <QLocale> +#include <QTranslator> + +namespace { +class AppTranslator : public QTranslator +{ +public: + explicit AppTranslator(QObject *parent) + : QTranslator(parent) + { + qApp->installTranslator(this); + } + + ~AppTranslator() override + { + qApp->removeTranslator(this); + } +}; + +void ensureNotificationTranslations() +{ + static bool initialized = false; + if (initialized) { + return; + } + + QCoreApplication *app = QCoreApplication::instance(); + if (!app) { + return; + } + + AppTranslator *engineeringEnglish = new AppTranslator(app); + engineeringEnglish->load(QStringLiteral("lipstick-jolla-home-mastodon-notifications_eng_en"), + QStringLiteral("/usr/share/translations")); + + AppTranslator *translator = new AppTranslator(app); + translator->load(QLocale(), + QStringLiteral("lipstick-jolla-home-mastodon-notifications"), + QStringLiteral("-"), + QStringLiteral("/usr/share/translations")); + + initialized = true; +} +} + MastodonNotificationsPlugin::MastodonNotificationsPlugin(const QString& pluginName, const Buteo::SyncProfile& profile, Buteo::PluginCbInterface *callbackInterface) @@ -29,6 +75,7 @@ MastodonNotificationsPlugin::MastodonNotificationsPlugin(const QString& pluginNa QStringLiteral("mastodon"), SocialNetworkSyncAdaptor::dataTypeName(SocialNetworkSyncAdaptor::Notifications)) { + ensureNotificationTranslations(); } MastodonNotificationsPlugin::~MastodonNotificationsPlugin() |
