StelTranslator.cpp   StelTranslator.cpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* 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.
*/ */
#ifdef _MSC_BUILD
#include "kdewin32/dirent.h"
#else
#include <dirent.h> #include <dirent.h>
#endif
#include <cstdio> #include <cstdio>
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#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 <QDir>
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelFileMgr.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;
skipping to change at line 71 skipping to change at line 76
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 Q_OS_WIN #ifdef Q_OS_WIN
char ulng[3], ctry[3]; char ulng[3], ctry[3];
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO63 9LANGNAME, ulng, 3)) if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO6 39LANGNAME, ulng, 3))
{ {
ulng[2] = '\0'; ulng[2] = '\0';
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCAL E_SISO3166CTRYNAME, ctry, 3)) if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCA LE_SISO3166CTRYNAME, ctry, 3))
{ {
ctry[2] = '\0'; ctry[2] = '\0';
systemLangName = QString("%1_%2").ar g(ulng).arg(ctry); systemLangName = QString("%1_%2").ar g(ulng).arg(ctry);
} }
else else
{ {
systemLangName = ulng; systemLangName = ulng;
} }
} }
else else
skipping to change at line 217 skipping to change at line 222
{ {
QString locDir = localeDir; QString locDir = localeDir;
if (locDir.isEmpty()) if (locDir.isEmpty())
locDir = moDirectory; locDir = moDirectory;
struct dirent *entryp; struct dirent *entryp;
DIR *dp; DIR *dp;
QStringList result; QStringList result;
if ((dp = opendir(QFile::encodeName(locDir).constData())) == NULL) if ((dp = opendir(QFile::encodeName(locDir).constData())) == NULL)
{ {
qWarning() << "Unable to find locale directory containing tr anslations:" << localeDir; qWarning() << "Unable to find locale directory containing tr anslations:" << QDir::toNativeSeparators(localeDir);
return result; return result;
} }
while ((entryp = readdir(dp)) != NULL) while ((entryp = readdir(dp)) != NULL)
{ {
QString tmp = entryp->d_name; QString tmp = entryp->d_name;
QString tmpdir = locDir+"/"+tmp+"/LC_MESSAGES/stellarium.mo" ; QString tmpdir = locDir+"/"+tmp+"/LC_MESSAGES/stellarium.mo" ;
FILE* fic = fopen(QFile::encodeName(tmpdir).constData(), "r" ); FILE* fic = fopen(QFile::encodeName(tmpdir).constData(), "r" );
if (fic) if (fic)
{ {
skipping to change at line 247 skipping to change at line 252
return result; return result;
} }
//! Initialize the languages code list from the passed file //! Initialize the languages code list from the passed file
//! @param fileName file containing the list of language codes //! @param fileName file containing the list of language codes
void StelTranslator::initIso639_1LanguageCodes(const QString& fileName) void StelTranslator::initIso639_1LanguageCodes(const QString& fileName)
{ {
QFile inf(fileName); QFile inf(fileName);
if (!inf.open(QIODevice::ReadOnly)) if (!inf.open(QIODevice::ReadOnly))
{ {
qWarning() << "Can't open ISO639 codes file " << fileName; qWarning() << "Can't open ISO639 codes file " << QDir::toNat iveSeparators(fileName);
Q_ASSERT(0); Q_ASSERT(0);
} }
if (!iso639codes.empty()) if (!iso639codes.empty())
iso639codes.clear(); iso639codes.clear();
while (!inf.atEnd()) while (!inf.atEnd())
{ {
QString record = QString::fromUtf8(inf.readLine()); QString record = QString::fromUtf8(inf.readLine());
record.remove(QRegExp("[\\n\\r]*$")); // chomp new lines record.remove(QRegExp("[\\n\\r]*$")); // chomp new lines
 End of changes. 7 change blocks. 
4 lines changed or deleted 9 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/