Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 a092f56
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/app/qgsoptions.cpp
Expand Up @@ -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 ) );
Expand All @@ -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();
Expand Down

0 comments on commit a092f56

Please sign in to comment.