2017-04-27 18:24:53 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "gettextfromc.h"
|
2018-06-17 19:03:16 +00:00
|
|
|
#include <QHash>
|
2018-06-17 21:28:44 +00:00
|
|
|
#include <QMutex>
|
2013-10-06 15:55:58 +00:00
|
|
|
|
2018-06-17 19:03:16 +00:00
|
|
|
static QHash<QByteArray, QByteArray> translationCache;
|
2018-06-17 21:28:44 +00:00
|
|
|
static QMutex lock;
|
2018-06-17 19:03:16 +00:00
|
|
|
|
|
|
|
extern "C" const char *trGettext(const char *text)
|
2013-10-06 15:55:58 +00:00
|
|
|
{
|
2018-06-17 21:28:44 +00:00
|
|
|
QByteArray key(text);
|
|
|
|
QMutexLocker l(&lock);
|
|
|
|
auto it = translationCache.find(key);
|
|
|
|
if (it == translationCache.end())
|
|
|
|
it = translationCache.insert(key, gettextFromC::tr(text).toUtf8());
|
|
|
|
return it->constData();
|
2013-10-09 05:44:38 +00:00
|
|
|
}
|