Alwayse show locale "en_US" in the language list.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-11-14 19:35:26 +02:00
parent 973e2563af
commit e881547999
2 changed files with 22 additions and 6 deletions

View File

@ -144,6 +144,9 @@ QGroupBox *TapeConfigurationPage::LangGroup()
fileNames.append(it.fileName());
}
bool englishUS = false;
const QString en_US = QStringLiteral("en_US");
for (int i = 0; i < fileNames.size(); ++i)
{
// get locale extracted by filename
@ -151,6 +154,11 @@ QGroupBox *TapeConfigurationPage::LangGroup()
locale.truncate(locale.lastIndexOf(QLatin1String("."))); // "valentina_de_De"
locale.remove(0, locale.indexOf(QLatin1String("_")) + 1); // "de_De"
if (not englishUS)
{
englishUS = (en_US == locale);
}
const QLocale loc(locale);
const QString lang = loc.nativeLanguageName();
QIcon ico(QString("%1/%2.png").arg("://flags").arg(QLocale::countryToString(loc.country())));
@ -158,12 +166,12 @@ QGroupBox *TapeConfigurationPage::LangGroup()
langCombo->addItem(ico, lang, locale);
}
if (langCombo->count() == 0)
if (langCombo->count() == 0 || not englishUS)
{
// English language is internal and doens't have own *.qm file.
QIcon ico(QString("%1/%2.png").arg("://flags").arg(QLocale::countryToString(QLocale::UnitedStates)));
const QString lang = QLocale("en_US").nativeLanguageName();
langCombo->addItem(ico, lang, "en_US");
const QString lang = QLocale(en_US).nativeLanguageName();
langCombo->addItem(ico, lang, en_US);
}
// set default translators and language checked

View File

@ -203,6 +203,9 @@ QGroupBox *ConfigurationPage::LangGroup()
fileNames.append(it.fileName());
}
bool englishUS = false;
const QString en_US = QStringLiteral("en_US");
for (int i = 0; i < fileNames.size(); ++i)
{
// get locale extracted by filename
@ -211,6 +214,11 @@ QGroupBox *ConfigurationPage::LangGroup()
locale.truncate(locale.lastIndexOf('.')); // "valentina_de_De"
locale.remove(0, locale.indexOf('_') + 1); // "de_De"
if (not englishUS)
{
englishUS = (en_US == locale);
}
QLocale loc = QLocale(locale);
QString lang = loc.nativeLanguageName();
QIcon ico(QString("%1/%2.png").arg("://flags").arg(QLocale::countryToString(loc.country())));
@ -218,12 +226,12 @@ QGroupBox *ConfigurationPage::LangGroup()
langCombo->addItem(ico, lang, locale);
}
if (langCombo->count() == 0)
if (langCombo->count() == 0 || not englishUS)
{
// English language is internal and doens't have own *.qm file.
QIcon ico(QString("%1/%2.png").arg("://flags").arg(QLocale::countryToString(QLocale::UnitedStates)));
QString lang = QLocale("en_US").nativeLanguageName();
langCombo->addItem(ico, lang, "en_US");
QString lang = QLocale(en_US).nativeLanguageName();
langCombo->addItem(ico, lang, en_US);
}
// set default translators and language checked