StelTranslator.cpp   StelTranslator.cpp 
skipping to change at line 24 skipping to change at line 24
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include <cstdio>
#include <algorithm>
#include <fstream>
#include <clocale>
#include <cstdlib>
#include <QtGlobal>
#ifdef Q_OS_WIN
#include <winsock2.h>
#include <windows.h>
#endif
#include <QFile> #include <QFile>
#include <QDebug> #include <QDebug>
#include <QStringList> #include <QStringList>
#include <QRegExp> #include <QRegExp>
#include <QLocale> #include <QLocale>
#include <QDir> #include <QDir>
#include <QTranslator> #include <QTranslator>
// Init static members // Init static members
QMap<QString, QString> StelTranslator::iso639codes; QMap<QString, QString> StelTranslator::iso639codes;
QString StelTranslator::systemLangName; QString StelTranslator::systemLangName;
// Use system locale language by default // Use system locale language by default
StelTranslator* StelTranslator::globalTranslator = NULL; StelTranslator* StelTranslator::globalTranslator = Q_NULLPTR;
StelTranslator::StelTranslator(const QString& adomain, const QString& alang Name) StelTranslator::StelTranslator(const QString& adomain, const QString& alang Name)
: domain(adomain), : domain(adomain),
langName(alangName) langName(alangName)
{ {
translator = new QTranslator(); translator = new QTranslator();
bool res = translator->load(StelFileMgr::getLocaleDir()+"/"+adomain+ "/"+getTrueLocaleName()+".qm"); bool res = translator->load(StelFileMgr::getLocaleDir()+"/"+adomain+ "/"+getTrueLocaleName()+".qm");
if (!res) if (!res)
qWarning() << "Couldn't load translations for language " << getTrueLocaleName() << "in section" << adomain; qWarning() << "Couldn't load translations for language " << getTrueLocaleName() << "in section" << adomain;
if (translator->isEmpty()) if (translator->isEmpty())
qWarning() << "Empty translation file for language " << getT rueLocaleName() << "in section" << adomain; qWarning() << "Empty translation file for language " << getT rueLocaleName() << "in section" << adomain;
} }
StelTranslator::~StelTranslator() StelTranslator::~StelTranslator()
{ {
delete translator; delete translator;
translator = NULL; translator = Q_NULLPTR;
} }
QString StelTranslator::qtranslate(const QString& s, const QString& c) cons t QString StelTranslator::qtranslate(const QString& s, const QString& c) cons t
{ {
if (s.isEmpty()) if (s.isEmpty())
return ""; return "";
QString res = translator->translate("", s.toUtf8().constData(), c.to Utf8().constData()); QString res = translator->translate("", s.toUtf8().constData(), c.to Utf8().constData());
if (res.isEmpty()) if (res.isEmpty())
return s; return s;
return res; return res;
skipping to change at line 90 skipping to change at line 79
return translator->translate("", s.toUtf8().constData(),c.toUtf8().c onstData()); return translator->translate("", s.toUtf8().constData(),c.toUtf8().c onstData());
} }
//! Initialize Translation //! Initialize Translation
//! @param fileName file containing the list of language codes //! @param fileName file containing the list of language codes
void StelTranslator::init(const QString& fileName) void StelTranslator::init(const QString& fileName)
{ {
StelTranslator::initSystemLanguage(); StelTranslator::initSystemLanguage();
StelTranslator::initIso639_1LanguageCodes(fileName); StelTranslator::initIso639_1LanguageCodes(fileName);
Q_ASSERT(StelTranslator::globalTranslator==NULL); Q_ASSERT(StelTranslator::globalTranslator==Q_NULLPTR);
StelTranslator::globalTranslator = new StelTranslator("stellarium", "system"); StelTranslator::globalTranslator = new StelTranslator("stellarium", "system");
} }
//! Try to determine system language from system configuration //! Try to determine system language from system configuration
void StelTranslator::initSystemLanguage() void StelTranslator::initSystemLanguage()
{ {
systemLangName = QLocale::system().name(); systemLangName = QLocale::system().name();
if (systemLangName.isEmpty()) if (systemLangName.isEmpty())
systemLangName = "en"; systemLangName = "en";
 End of changes. 4 change blocks. 
14 lines changed or deleted 3 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/