Skip to content

Commit ee64c9e

Browse files
committed
Collect list of available locales instead of using
... the translations available in QGIS.
1 parent 9404200 commit ee64c9e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/app/qgsoptions.cpp

+18-2
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
903903
mOffsetYSpinBox->setValue( mSettings->value( QStringLiteral( "LayoutDesigner/defaultSnapGridOffsetY" ), 0, QgsSettings::Gui ).toDouble() );
904904

905905
//
906-
// Locale settings
906+
// Translation and locale settings
907907
//
908908
QString mySystemLocale = QLocale().name();
909909
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
916916
// QTBUG-57802: eo locale is improperly handled
917917
QString displayName = l.startsWith( QLatin1String( "eo" ) ) ? QLocale::languageToString( QLocale::Esperanto ) : QLocale( l ).nativeLanguageName();
918918
cboTranslation->addItem( QIcon( QString( ":/images/flags/%1.svg" ).arg( l ) ), displayName, l );
919-
cboGlobalLocale->addItem( QIcon( QString( ":/images/flags/%1.svg" ).arg( l ) ), displayName, l );
920919
}
920+
921+
const QList<QLocale> allLocales = QLocale::matchingLocales(
922+
QLocale::AnyLanguage,
923+
QLocale::AnyScript,
924+
QLocale::AnyCountry );
925+
926+
QSet<QString> addedLocales;
927+
for ( const auto &l : allLocales )
928+
{
929+
// Do not add duplicates (like en_US)
930+
if ( ! addedLocales.contains( l.name() ) )
931+
{
932+
cboGlobalLocale->addItem( QStringLiteral( "%1 %2 (%3)" ).arg( QLocale::languageToString( l.language() ), QLocale::countryToString( l.country() ), l.name() ), l.name() );
933+
addedLocales.insert( l.name() );
934+
}
935+
}
936+
921937
cboTranslation->setCurrentIndex( cboTranslation->findData( myUserLocale ) );
922938
cboGlobalLocale->setCurrentIndex( cboGlobalLocale->findData( myGlobalLocale ) );
923939
bool myLocaleOverrideFlag = mSettings->value( QStringLiteral( "locale/overrideFlag" ), false ).toBool();

0 commit comments

Comments
 (0)