StelTranslator.cpp   StelTranslator.cpp 
skipping to change at line 78 skipping to change at line 78
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;
} }
QString StelTranslator::tryQtranslate(const QString &s, const QString &c) c
onst
{
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==NULL);
StelTranslator::globalTranslator = new StelTranslator("stellarium", "system"); StelTranslator::globalTranslator = new StelTranslator("stellarium", "system");
} }
skipping to change at line 138 skipping to change at line 143
{ {
QMap<QString, QString>::ConstIterator iter; QMap<QString, QString>::ConstIterator iter;
for (iter=iso639codes.begin();iter!=iso639codes.end();++iter) for (iter=iso639codes.begin();iter!=iso639codes.end();++iter)
if (iter.value() == languageName) if (iter.value() == languageName)
return iter.key(); return iter.key();
return languageName; return languageName;
} }
//! Get available native language names from directory tree //! Get available native language names from directory tree
QStringList StelTranslator::getAvailableLanguagesNamesNative(const QString& localeDir) const QStringList StelTranslator::getAvailableLanguagesNamesNative(const QString& localeDir, const QString& section) const
{ {
QString tmpDir = localeDir; QString tmpDir = localeDir;
if (section.isEmpty() || section=="stellarium")
tmpDir.append("/stellarium/");
else
tmpDir.append("/stellarium-" + section + "/");
QStringList codeList = getAvailableIso639_1Codes(tmpDir); QStringList codeList = getAvailableIso639_1Codes(tmpDir);
QStringList output; QStringList output;
foreach (const QString& lang, codeList) foreach (const QString& lang, codeList)
{ {
output += iso639_1CodeToNativeName(lang); output += iso639_1CodeToNativeName(lang);
} }
return output; return output;
} }
//! Get available language codes from directory tree //! Get available language codes from directory tree
QStringList StelTranslator::getAvailableIso639_1Codes(const QString& locale Dir) const QStringList StelTranslator::getAvailableIso639_1Codes(const QString& locale Dir) const
{ {
QDir dir(localeDir+"/stellarium/"); QDir dir(localeDir);
if (!dir.exists()) if (!dir.exists())
{ {
qWarning() << "Unable to find locale directory containing tr anslations:" << QDir::toNativeSeparators(localeDir); qWarning() << "Unable to find locale directory containing tr anslations:" << QDir::toNativeSeparators(localeDir);
return QStringList(); return QStringList();
} }
QStringList result; QStringList result;
foreach (QString path, dir.entryList(QDir::Files, QDir::Name)) foreach (QString path, dir.entryList(QDir::Files, QDir::Name))
{ {
 End of changes. 4 change blocks. 
2 lines changed or deleted 13 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/