2013-10-06 15:55:58 +00:00
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QString>
|
|
|
|
#include <gettextfromc.h>
|
|
|
|
|
2013-10-10 07:15:21 +00:00
|
|
|
const char *gettextFromC::trGettext(const char *text)
|
2013-10-06 15:55:58 +00:00
|
|
|
{
|
2013-11-01 17:23:06 +00:00
|
|
|
QByteArray &result = translationCache[QByteArray(text)];
|
2013-10-09 05:44:38 +00:00
|
|
|
if (result.isEmpty())
|
2015-01-29 21:35:28 +00:00
|
|
|
result = translationCache[QByteArray(text)] = trUtf8(text).toUtf8();
|
2013-10-09 05:44:38 +00:00
|
|
|
return result.constData();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gettextFromC::reset(void)
|
|
|
|
{
|
|
|
|
translationCache.clear();
|
2013-10-06 15:55:58 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
gettextFromC *gettextFromC::instance()
|
2013-10-06 15:55:58 +00:00
|
|
|
{
|
2013-11-30 17:18:04 +00:00
|
|
|
static QScopedPointer<gettextFromC> self(new gettextFromC());
|
|
|
|
return self.data();
|
2013-10-06 15:55:58 +00:00
|
|
|
}
|
|
|
|
|
2013-10-10 07:15:21 +00:00
|
|
|
extern "C" const char *trGettext(const char *text)
|
2013-10-06 15:55:58 +00:00
|
|
|
{
|
2013-10-10 07:15:21 +00:00
|
|
|
return gettextFromC::instance()->trGettext(text);
|
2013-10-06 15:55:58 +00:00
|
|
|
}
|