StelTranslator.cpp   StelTranslator.cpp 
skipping to change at line 35 skipping to change at line 35
#include <clocale> #include <clocale>
#include <cstdlib> #include <cstdlib>
#include <QFile> #include <QFile>
#include <QDebug> #include <QDebug>
#include <QStringList> #include <QStringList>
#include <QRegExp> #include <QRegExp>
#include <QLocale> #include <QLocale>
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelFileMgr.hpp"
// Init static members // Init static members
StelTranslator* StelTranslator::lastUsed = NULL; StelTranslator* StelTranslator::lastUsed = NULL;
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
#if defined(MACOSX) StelTranslator StelTranslator::globalTranslator = StelTranslator("stellariu
#include "StelMacosxDirs.hpp" m", "./locale/", "system");
StelTranslator StelTranslator::globalTranslator = StelTranslator(PACKAGE_NA
ME, StelMacosxDirs::getApplicationResourcesDirectory().append( "/locale" ),
"system");
#else
StelTranslator StelTranslator::globalTranslator = StelTranslator(PACKAGE_NA
ME, INSTALL_LOCALEDIR, "system");
#endif
#ifdef WIN32 #ifdef Q_OS_WIN
# include <windows.h> # include <windows.h>
# include <winnls.h> # include <winnls.h>
#define putenv(x) _putenv((x)) #define putenv(x) _putenv((x))
#endif #endif
//! 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();
skipping to change at line 74 skipping to change at line 70
void StelTranslator::initSystemLanguage(void) void StelTranslator::initSystemLanguage(void)
{ {
char* lang = getenv("LANGUAGE"); char* lang = getenv("LANGUAGE");
if (lang) systemLangName = lang; if (lang) systemLangName = lang;
else else
{ {
lang = getenv("LANG"); lang = getenv("LANG");
if (lang) systemLangName = lang; if (lang) systemLangName = lang;
else else
{ {
#ifdef WIN32 #ifdef Q_OS_WIN
char cc[3]; char cc[3];
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO63 9LANGNAME, cc, 3)) if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO63 9LANGNAME, cc, 3))
{ {
cc[2] = '\0'; cc[2] = '\0';
systemLangName = cc; systemLangName = cc;
} }
else else
{ {
systemLangName = "C"; systemLangName = "C";
} }
skipping to change at line 111 skipping to change at line 107
return; return;
// Find out what the system language is if not defined yet // Find out what the system language is if not defined yet
if (systemLangName.isEmpty()) if (systemLangName.isEmpty())
initSystemLanguage(); initSystemLanguage();
// Apply that // Apply that
// This needs to be static as it is used a each gettext call... It t ooks me quite a while before I got that :( // This needs to be static as it is used a each gettext call... It t ooks me quite a while before I got that :(
static char envstr[25]; static char envstr[25];
if (langName=="system" || langName=="system_default") if (langName=="system" || langName=="system_default")
#if defined (MACOSX) // MACOSX #ifdef Q_OS_MAC
{ {
snprintf(envstr, 25, "LANG=%s", StelTranslator::systemLangNa me.toUtf8().constData()); snprintf(envstr, 25, "LANG=%s", StelTranslator::systemLangNa me.toUtf8().constData());
} }
else else
{ {
snprintf(envstr, 25, "LANG=%s", langName.toUtf8().constData( )); snprintf(envstr, 25, "LANG=%s", langName.toUtf8().constData( ));
} }
#elif defined (_MSC_VER) //MSCVER #elif defined (Q_OS_WIN) //MSCVER
{ {
_snprintf(envstr, 25, "LANGUAGE=%s", StelTranslator::systemL angName.toUtf8().constData()); _snprintf(envstr, 25, "LANGUAGE=%s", StelTranslator::systemL angName.toUtf8().constData());
} }
else else
{ {
_snprintf(envstr, 25, "LANGUAGE=%s", langName.toUtf8().const Data()); _snprintf(envstr, 25, "LANGUAGE=%s", langName.toUtf8().const Data());
} }
#else // UNIX #else // UNIX
{ {
snprintf(envstr, 25, "LANGUAGE=%s", StelTranslator::systemLa ngName.toUtf8().constData()); snprintf(envstr, 25, "LANGUAGE=%s", StelTranslator::systemLa ngName.toUtf8().constData());
} }
else else
{ {
snprintf(envstr, 25, "LANGUAGE=%s", langName.toUtf8().constD ata()); snprintf(envstr, 25, "LANGUAGE=%s", langName.toUtf8().constD ata());
} }
#endif #endif
putenv(envstr); putenv(envstr);
#if !defined (WIN32) #ifndef Q_OS_WIN
setlocale(LC_MESSAGES, ""); setlocale(LC_MESSAGES, "");
#else #else
setlocale(LC_CTYPE,""); setlocale(LC_CTYPE,"");
#endif #endif
QString result = bind_textdomain_codeset(domain.toUtf8().constData() , "UTF-8"); QString result = bind_textdomain_codeset(domain.toUtf8().constData() , "UTF-8");
Q_ASSERT(result=="UTF-8"); Q_ASSERT(result=="UTF-8");
bindtextdomain (domain.toUtf8().constData(), QFile::encodeName(moDir ectory).constData()); bindtextdomain (domain.toUtf8().constData(), QFile::encodeName(moDir ectory).constData());
textdomain (domain.toUtf8().constData()); textdomain (domain.toUtf8().constData());
StelTranslator::lastUsed = this; StelTranslator::lastUsed = this;
} }
 End of changes. 7 change blocks. 
14 lines changed or deleted 8 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/