[locale] prefer native language and country names when available
This basically means we talk about localization in the respective localized variant. e.g. "German (Germany)" ➡ "Deutsch (Deutschland)". If geoip lookup failed or isn't configured for whatever reason it's a stretch to expect the user to know english enough to find their own language. Preferring the localized strings resolves this issue. Additionally this happens to bypass #712 respectively https://bugreports.qt.io/browse/QTBUG-34287 as the native names are properly spelled. So, as long as Qt has localized names the names will also be properly spelled.
This commit is contained in:
parent
0b6e1ca488
commit
311af6de5d
@ -369,6 +369,8 @@ KeyboardPage::onActivate()
|
||||
{
|
||||
const auto langParts = lang.split( '_', QString::SkipEmptyParts );
|
||||
|
||||
// Note that this his string is not fit for display purposes!
|
||||
// It doesn't come from QLocale::nativeCountryName.
|
||||
QString country = QLocale::countryToString( QLocale( lang ).country() );
|
||||
cDebug() << " .. extracted country" << country << "::" << langParts;
|
||||
|
||||
|
@ -477,8 +477,13 @@ LocalePage::prettyLCLocale( const QString& lcLocale ) const
|
||||
|
||||
QLocale locale( localeString );
|
||||
//: Language (Country)
|
||||
return tr( "%1 (%2)" ).arg( QLocale::languageToString( locale.language() ) )
|
||||
.arg( QLocale::countryToString( locale.country() ) );
|
||||
const QString lang = !locale.nativeLanguageName().isEmpty() ?
|
||||
locale.nativeLanguageName() :
|
||||
QLocale::languageToString( locale.language() );
|
||||
const QString country = !locale.nativeCountryName().isEmpty() ?
|
||||
locale.nativeCountryName() :
|
||||
QLocale::countryToString( locale.country() );
|
||||
return tr( "%1 (%2)" ).arg( lang ).arg( country );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -345,4 +345,3 @@ WelcomePage::focusInEvent( QFocusEvent* e )
|
||||
ui->languageWidget->setFocus();
|
||||
e->accept();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user