diff options
| author | Andrew Branson <andrew.branson@jolla.com> | 2026-03-19 16:48:51 +0100 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@jolla.com> | 2026-03-19 16:48:51 +0100 |
| commit | c08a37b96fec1706a1eb560255d487ec6c8a05dc (patch) | |
| tree | 5f2c3f059a5bce53e2bd189a40fd50c2a68d555d /buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationsplugin.cpp | |
| parent | 5fe5ede124da1824fd3b055ec480bf9ce4a5b83f (diff) | |
Sync with main
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() |
