GUI: fix SuggestLanguage for zh_CN

This commit is contained in:
Xuecheng Zhang 2014-01-23 06:32:41 +01:00 committed by Daniel Marjamäki
parent ec034c1d59
commit 50d0aa1870
1 changed files with 8 additions and 8 deletions

View File

@ -146,13 +146,8 @@ QString TranslationHandler::GetCurrentLanguage() const
QString TranslationHandler::SuggestLanguage() const QString TranslationHandler::SuggestLanguage() const
{ {
/* //Get language from system locale's name ie sv_SE or zh_CN
Get language from system locale's name QString language = QLocale::system().name();
QLocale::languageToString would return the languages full name and we
only want two-letter ISO 639 language code so we'll get it from
locale's name.
*/
QString language = QLocale::system().name().left(2);
//qDebug()<<"Your language is"<<language; //qDebug()<<"Your language is"<<language;
//And see if we can find it from our list of language files //And see if we can find it from our list of language files
@ -171,7 +166,8 @@ void TranslationHandler::AddTranslation(const char *name, const char *filename)
TranslationInfo info; TranslationInfo info;
info.mName = name; info.mName = name;
info.mFilename = filename; info.mFilename = filename;
info.mCode = QString(filename).right(2); int codeLength = QString(filename).length() - QString(filename).indexOf('_') - 1;
info.mCode = QString(filename).right(codeLength);
mTranslations.append(info); mTranslations.append(info);
} }
@ -183,6 +179,10 @@ int TranslationHandler::GetLanguageIndexByCode(const QString &code) const
index = i; index = i;
break; break;
} }
else if (mTranslations[i].mCode == code.left(2)) {
index = i;
break;
}
} }
return index; return index;
} }