Skip to content
Permalink
Browse files

Collect list of available locales instead of using

... the translations available in QGIS.
  • Loading branch information
elpaso committed Jul 2, 2018
1 parent 217b851 commit a092f56dd20580843ae2070db3f001683876adfe
Showing with 18 additions and 2 deletions.
  1. +18 −2 src/app/qgsoptions.cpp
@@ -903,7 +903,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
mOffsetYSpinBox->setValue( mSettings->value( QStringLiteral( "LayoutDesigner/defaultSnapGridOffsetY" ), 0, QgsSettings::Gui ).toDouble() );

//
// Locale settings
// Translation and locale settings
//
QString mySystemLocale = QLocale().name();
lblSystemLocale->setText( tr( "Detected active locale on your system: %1" ).arg( mySystemLocale ) );
@@ -916,8 +916,24 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
// QTBUG-57802: eo locale is improperly handled
QString displayName = l.startsWith( QLatin1String( "eo" ) ) ? QLocale::languageToString( QLocale::Esperanto ) : QLocale( l ).nativeLanguageName();
cboTranslation->addItem( QIcon( QString( ":/images/flags/%1.svg" ).arg( l ) ), displayName, l );
cboGlobalLocale->addItem( QIcon( QString( ":/images/flags/%1.svg" ).arg( l ) ), displayName, l );
}

const QList<QLocale> allLocales = QLocale::matchingLocales(
QLocale::AnyLanguage,
QLocale::AnyScript,
QLocale::AnyCountry );

QSet<QString> addedLocales;
for ( const auto &l : allLocales )
{
// Do not add duplicates (like en_US)
if ( ! addedLocales.contains( l.name() ) )
{
cboGlobalLocale->addItem( QStringLiteral( "%1 %2 (%3)" ).arg( QLocale::languageToString( l.language() ), QLocale::countryToString( l.country() ), l.name() ), l.name() );
addedLocales.insert( l.name() );
}
}

cboTranslation->setCurrentIndex( cboTranslation->findData( myUserLocale ) );
cboGlobalLocale->setCurrentIndex( cboGlobalLocale->findData( myGlobalLocale ) );
bool myLocaleOverrideFlag = mSettings->value( QStringLiteral( "locale/overrideFlag" ), false ).toBool();

0 comments on commit a092f56

Please sign in to comment.
You can’t perform that action at this time.