[welcome] Fix matched-with-a-locale

- Previously the matchLocale() function set the index in the
   combobox; do it separately now.
This commit is contained in:
Adriaan de Groot 2019-04-19 10:15:57 +02:00
parent 57452b8c38
commit e5d1c0ae27

View File

@ -137,13 +137,13 @@ WelcomePage::initLanguages()
// Find the best initial translation // Find the best initial translation
QLocale defaultLocale = QLocale( QLocale::system().name() ); QLocale defaultLocale = QLocale( QLocale::system().name() );
cDebug() << "Matching exact locale" << defaultLocale; cDebug() << "Matching locale" << defaultLocale;
int matchedLocaleIndex = m_languages->find( int matchedLocaleIndex = m_languages->find(
[&](const QLocale& x){ return x.language() == defaultLocale.language() && x.country() == defaultLocale.country(); } ); [&](const QLocale& x){ return x.language() == defaultLocale.language() && x.country() == defaultLocale.country(); } );
if ( matchedLocaleIndex < 0 ) if ( matchedLocaleIndex < 0 )
{ {
cDebug() << "Matching approximate locale" << defaultLocale.language(); cDebug() << Logger::SubEntry << "Matching approximate locale" << defaultLocale.language();
matchedLocaleIndex = m_languages->find( matchedLocaleIndex = m_languages->find(
[&](const QLocale& x){ return x.language() == defaultLocale.language(); } ); [&](const QLocale& x){ return x.language() == defaultLocale.language(); } );
@ -153,7 +153,7 @@ WelcomePage::initLanguages()
{ {
QLocale en_us( QLocale::English, QLocale::UnitedStates ); QLocale en_us( QLocale::English, QLocale::UnitedStates );
cDebug() << "Matching English (US)"; cDebug() << Logger::SubEntry << "Matching English (US)";
matchedLocaleIndex = m_languages->find( en_us ); matchedLocaleIndex = m_languages->find( en_us );
// Now, if it matched, because we didn't match the system locale, switch to the one found // Now, if it matched, because we didn't match the system locale, switch to the one found
@ -162,9 +162,13 @@ WelcomePage::initLanguages()
} }
if ( matchedLocaleIndex >= 0 ) if ( matchedLocaleIndex >= 0 )
CalamaresUtils::installTranslator( m_languages->locale( matchedLocaleIndex ).name(), {
Calamares::Branding::instance()->translationsPathPrefix(), QString name = m_languages->locale( matchedLocaleIndex ).name();
qApp ); cDebug() << Logger::SubEntry << "Matched with index" << matchedLocaleIndex << name;
CalamaresUtils::installTranslator( name, Calamares::Branding::instance()->translationsPathPrefix(), qApp );
ui->languageWidget->setCurrentIndex( matchedLocaleIndex );
}
else else
cWarning() << "No available translation matched" << defaultLocale; cWarning() << "No available translation matched" << defaultLocale;