[libcalamaresui] Drop now-unused sortKey from LocaleLabel

- sortKey is unused
 - add englishLabel for reverse-i18n
main
Adriaan de Groot 6 years ago
parent 5e951466df
commit 620940c75b

@ -269,26 +269,20 @@ LocaleLabel::LocaleLabel( const QString& locale, LabelFormat format )
//: language[name] (country[name])
QString longFormat = QObject::tr( "%1 (%2)" );
QString sortKey = QLocale::languageToString( m_locale.language() );
QString languageName = m_locale.nativeLanguageName();
QString englishName = m_locale.languageToString( m_locale.language() );
QString countryName;
if ( languageName.isEmpty() )
languageName = QString( QLatin1Literal( "* %1 (%2)" ) ).arg( locale, sortKey );
languageName = QString( QLatin1Literal( "* %1 (%2)" ) ).arg( locale, englishName );
bool needsCountryName = ( format == LabelFormat::AlwaysWithCountry ) ||
(locale.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 1 );
if ( needsCountryName )
{
sortKey.append( '+' );
sortKey.append( QLocale::countryToString( m_locale.country() ) );
countryName = m_locale.nativeCountryName();
}
m_sortKey = sortKey;
m_label = needsCountryName ? longFormat.arg( languageName ).arg( countryName ) : languageName;
m_englishLabel = englishName;
}
QLocale LocaleLabel::getLocale( const QString& localeName )

@ -172,6 +172,12 @@ public:
{
return m_label;
}
/** @brief Get the *English* human-readable name for this locale. */
QString englishLabel() const
{
return m_englishLabel;
}
/** @brief Get the Qt locale. */
QLocale locale() const
{
@ -188,8 +194,8 @@ public:
protected:
QLocale m_locale;
QString m_localeId; // the locale identifier, e.g. "en_GB"
QString m_sortKey; // the English name of the locale
QString m_label; // the native name of the locale
QString m_englishLabel;
} ;

Loading…
Cancel
Save