QTfrontend/ui/page/pageoptions.cpp
changeset 12165 1c3670021559
parent 11679 d59b6f289e30
child 12185 7df59356471e
equal deleted inserted replaced
12164:cb3e785534da 12165:1c3670021559
   624 
   624 
   625             CBLanguage = new QComboBox(groupMisc);
   625             CBLanguage = new QComboBox(groupMisc);
   626             CBLanguage->setMaxVisibleItems(50);
   626             CBLanguage->setMaxVisibleItems(50);
   627             groupMisc->layout()->addWidget(CBLanguage, 0, 1);
   627             groupMisc->layout()->addWidget(CBLanguage, 0, 1);
   628             QStringList locs = DataManager::instance().entryList("Locale", QDir::Files, QStringList("hedgewars_*.qm"));
   628             QStringList locs = DataManager::instance().entryList("Locale", QDir::Files, QStringList("hedgewars_*.qm"));
       
   629             QStringList langnames;
   629             CBLanguage->addItem(QComboBox::tr("(System default)"), QString());
   630             CBLanguage->addItem(QComboBox::tr("(System default)"), QString());
   630             for(int i = 0; i < locs.count(); i++)
   631             for(int i = 0; i < locs.count(); i++)
   631             {
   632             {
   632                 QString lname = locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1");
   633                 QString lname = locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1");
   633                 QLocale loc(lname);
   634                 QLocale loc = QLocale(lname);
   634                 CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", lname);
   635                 QString entryName;
       
   636                 // If local identifier has underscore, it means the country has been specified
       
   637                 if(lname.contains("_"))
       
   638                 {
       
   639                     // Append country name for disambiguation
       
   640                     // FIXME: These brackets are hardcoded and can't be translated. Luckily, these are rarely used and work with most languages anyway
       
   641                     entryName = loc.nativeLanguageName() + " (" + loc.nativeCountryName() + ")";
       
   642                 }
       
   643                 else
       
   644                 {
       
   645                     // Usually, we just print the language name
       
   646                     entryName = loc.nativeLanguageName();
       
   647                 }
       
   648                 // Fallback code: If language name is empty for some reason, print locale identifier. This should normally not happen
       
   649                 if(entryName.isEmpty())
       
   650                 {
       
   651                     entryName = tr("MISSING LANGUAGE NAME [%1]").arg(lname);
       
   652                 }
       
   653                 CBLanguage->addItem(entryName, lname);
   635             }
   654             }
   636 
   655 
   637             QLabel *restartNoticeLabel = new QLabel(groupMisc);
   656             QLabel *restartNoticeLabel = new QLabel(groupMisc);
   638             restartNoticeLabel->setText(QLabel::tr("This setting will be effective at next restart."));
   657             restartNoticeLabel->setText(QLabel::tr("This setting will be effective at next restart."));
   639             groupMisc->layout()->addWidget(restartNoticeLabel, 1, 1);
   658             groupMisc->layout()->addWidget(restartNoticeLabel, 1, 1);