subsurface/gettextfromc.cpp
Dirk Hohndel 86a80d37eb Dismbiguate gettext
Just to make sure there's no confusion - we are NOT calling gettext. We
are calling tr from a gettext like interface.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-10 00:18:26 -07:00

27 lines
536 B
C++

#include <QCoreApplication>
#include <QString>
#include <gettextfromc.h>
const char *gettextFromC::trGettext(const char *text)
{
QByteArray &result = translationCache[text];
if (result.isEmpty())
result = tr(text).toUtf8();
return result.constData();
}
void gettextFromC::reset(void)
{
translationCache.clear();
}
gettextFromC* gettextFromC::instance()
{
static gettextFromC *self = new gettextFromC();
return self;
}
extern "C" const char *trGettext(const char *text)
{
return gettextFromC::instance()->trGettext(text);
}