20 #ifndef _STELTRANSLATOR_HPP_
21 #define _STELTRANSLATOR_HPP_
28 #include "StelUtils.hpp"
37 #define q_(str) StelTranslator::globalTranslator.qtranslate(str)
42 #define qc_(str, ctxt) StelTranslator::globalTranslator.qtranslate(str, ctxt)
47 #define N_(str) gettext_noop(str)
65 StelTranslator(
const QString& adomain,
const QString& amoDirectory,
const QString& alangName) :
66 domain(adomain), moDirectory(amoDirectory), langName(alangName)
68 StelTranslator::lastUsed = NULL;
75 QString
qtranslate(
const QString& s,
const QString& c = QString())
77 if (s.isEmpty())
return QString();
81 return QString::fromUtf8(gettext(s.toUtf8().constData()));
87 QByteArray bytesC = c.toUtf8();
88 QByteArray bytesS = s.toUtf8();
89 QByteArray glue(1, (
char)0x4);
90 QByteArray bytes = bytesC + glue + bytesS;
91 QString t = QString::fromUtf8(gettext(bytes.data()));
94 if (t.toUtf8() == bytes)
105 if (langName==
"system" || langName==
"system_default")
106 return StelTranslator::systemLangName;
126 static void init(
const QString& fileName);
131 static void initIso639_1LanguageCodes(
const QString& fileName);
134 QStringList getAvailableIso639_1Codes(
const QString& localeDir=
"")
const;
152 static void initSystemLanguage(
void);
155 static QString systemLangName;
158 static QMap<QString, QString> iso639codes;
161 #endif // _STELTRANSLATOR_HPP_