diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 94f2192c2..0baadd82f 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -121,32 +121,42 @@ void Config::initLanguages() { // Find the best initial translation - QLocale defaultLocale = QLocale( QLocale::system().name() ); + CalamaresUtils::Locale::Translation defaultTranslation; - cDebug() << "Matching locale" << defaultLocale; - int matchedLocaleIndex = m_languages->find( [&]( const QLocale& x ) { - return x.language() == defaultLocale.language() && x.country() == defaultLocale.country(); - } ); + cDebug() << "Trying to match locale" << defaultTranslation.id(); + int matchedLocaleIndex = m_languages->find( defaultTranslation.id() ); + // Need to match by some other means than the exact translation Id if ( matchedLocaleIndex < 0 ) { - cDebug() << Logger::SubEntry << "Matching approximate locale" << defaultLocale.language(); - matchedLocaleIndex - = m_languages->find( [&]( const QLocale& x ) { return x.language() == defaultLocale.language(); } ); - } + QLocale defaultLocale = defaultTranslation.locale(); - if ( matchedLocaleIndex < 0 ) - { - QLocale en_us( QLocale::English, QLocale::UnitedStates ); + cDebug() << "Trying to match locale" << defaultLocale; + matchedLocaleIndex = m_languages->find( + [ & ]( const QLocale& x ) + { return x.language() == defaultLocale.language() && x.country() == defaultLocale.country(); } ); - cDebug() << Logger::SubEntry << "Matching English (US)"; - matchedLocaleIndex = m_languages->find( en_us ); - - // Now, if it matched, because we didn't match the system locale, switch to the one found - if ( matchedLocaleIndex >= 0 ) + if ( matchedLocaleIndex < 0 ) { - QLocale::setDefault( m_languages->locale( matchedLocaleIndex ).locale() ); + cDebug() << Logger::SubEntry << "Trying to match approximate locale" << defaultLocale.language(); + + matchedLocaleIndex + = m_languages->find( [ & ]( const QLocale& x ) { return x.language() == defaultLocale.language(); } ); + } + + if ( matchedLocaleIndex < 0 ) + { + QLocale en_us( QLocale::English, QLocale::UnitedStates ); + + cDebug() << Logger::SubEntry << "Trying to match English (US)"; + matchedLocaleIndex = m_languages->find( en_us ); + + // Now, if it matched, because we didn't match the system locale, switch to the one found + if ( matchedLocaleIndex >= 0 ) + { + QLocale::setDefault( m_languages->locale( matchedLocaleIndex ).locale() ); + } } } @@ -156,7 +166,7 @@ Config::initLanguages() } else { - cWarning() << "No available translation matched" << defaultLocale; + cWarning() << "No available translation matched" << defaultTranslation.id() << defaultTranslation.locale(); } } @@ -191,7 +201,8 @@ Config::setLocaleIndex( int index ) QLocale::setDefault( selectedTranslation.locale() ); const auto* branding = Calamares::Branding::instance(); - CalamaresUtils::installTranslator( selectedTranslation.id(), branding ? branding->translationsDirectory() : QString() ); + CalamaresUtils::installTranslator( selectedTranslation.id(), + branding ? branding->translationsDirectory() : QString() ); if ( Calamares::JobQueue::instance() && Calamares::JobQueue::instance()->globalStorage() ) { CalamaresUtils::Locale::insertGS( *Calamares::JobQueue::instance()->globalStorage(), @@ -367,13 +378,16 @@ setGeoIP( Config* config, const QVariantMap& configurationMap ) if ( handler->type() != CalamaresUtils::GeoIP::Handler::Type::None ) { auto* future = new FWString(); - QObject::connect( future, &FWString::finished, [config, future, handler]() { - QString countryResult = future->future().result(); - cDebug() << "GeoIP result for welcome=" << countryResult; - ::setCountry( config, countryResult, handler ); - future->deleteLater(); - delete handler; - } ); + QObject::connect( future, + &FWString::finished, + [ config, future, handler ]() + { + QString countryResult = future->future().result(); + cDebug() << "GeoIP result for welcome=" << countryResult; + ::setCountry( config, countryResult, handler ); + future->deleteLater(); + delete handler; + } ); future->setFuture( handler->queryRaw() ); } else