summaryrefslogtreecommitdiffstats
path: root/core/gettextfromc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/gettextfromc.cpp')
-rw-r--r--core/gettextfromc.cpp25
1 files changed, 5 insertions, 20 deletions
diff --git a/core/gettextfromc.cpp b/core/gettextfromc.cpp
index e668fec2e..fdb1e6d37 100644
--- a/core/gettextfromc.cpp
+++ b/core/gettextfromc.cpp
@@ -1,28 +1,13 @@
// SPDX-License-Identifier: GPL-2.0
-#include <QCoreApplication>
-#include <QString>
#include "gettextfromc.h"
+#include <QHash>
-const char *gettextFromC::trGettext(const char *text)
+static QHash<QByteArray, QByteArray> translationCache;
+
+extern "C" const char *trGettext(const char *text)
{
QByteArray &result = translationCache[QByteArray(text)];
if (result.isEmpty())
- result = translationCache[QByteArray(text)] = trUtf8(text).toUtf8();
+ result = gettextFromC::tr(text).toUtf8();
return result.constData();
}
-
-void gettextFromC::reset(void)
-{
- translationCache.clear();
-}
-
-gettextFromC *gettextFromC::instance()
-{
- static gettextFromC self;
- return &self;
-}
-
-extern "C" const char *trGettext(const char *text)
-{
- return gettextFromC::instance()->trGettext(text);
-}