|
|
|
@ -270,26 +270,27 @@ LocaleLabel::LocaleLabel( const QString& locale )
|
|
|
|
|
: m_locale( LocaleLabel::getLocale( locale ) )
|
|
|
|
|
, m_localeId( locale )
|
|
|
|
|
{
|
|
|
|
|
QString longFormat = tr( "%1 (%2)", "Language (Country)" );
|
|
|
|
|
|
|
|
|
|
QString sortKey = QLocale::languageToString( m_locale.language() );
|
|
|
|
|
QString label = m_locale.nativeLanguageName();
|
|
|
|
|
QString languageName = m_locale.nativeLanguageName();
|
|
|
|
|
QString countryName;
|
|
|
|
|
|
|
|
|
|
if ( label.isEmpty() )
|
|
|
|
|
label = QString( QLatin1Literal( "* %1 (%2)" ) ).arg( locale, sortKey );
|
|
|
|
|
if ( languageName.isEmpty() )
|
|
|
|
|
languageName = QString( QLatin1Literal( "* %1 (%2)" ) ).arg( locale, sortKey );
|
|
|
|
|
|
|
|
|
|
if ( locale.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 2 )
|
|
|
|
|
{
|
|
|
|
|
QLatin1Literal countrySuffix( " (%1)" );
|
|
|
|
|
bool needsCountryName = locale.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 2;
|
|
|
|
|
|
|
|
|
|
sortKey.append( QString( countrySuffix ).arg( QLocale::countryToString( m_locale.country() ) ) );
|
|
|
|
|
if ( needsCountryName )
|
|
|
|
|
{
|
|
|
|
|
sortKey.append( '+' );
|
|
|
|
|
sortKey.append( QLocale::countryToString( m_locale.country() ) );
|
|
|
|
|
|
|
|
|
|
// If the language name is RTL, make this parenthetical addition RTL as well.
|
|
|
|
|
QString countryFormat = label.isRightToLeft() ? QString( QChar( 0x202B ) ) : QString();
|
|
|
|
|
countryFormat.append( countrySuffix );
|
|
|
|
|
label.append( countryFormat.arg( m_locale.nativeCountryName() ) );
|
|
|
|
|
countryName = m_locale.nativeCountryName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_sortKey = sortKey;
|
|
|
|
|
m_label = label;
|
|
|
|
|
m_label = needsCountryName ? longFormat.arg( languageName ).arg( countryName ) : languageName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QLocale LocaleLabel::getLocale( const QString& localeName )
|
|
|
|
|