From a09593e4a258d5dd5f596d1779d5a65a3a2df6d7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 28 Jan 2020 17:35:54 +0100 Subject: [PATCH] [locale] Tighten up language-matching - Drop plain startsWith() matching, since we now have "as" and "ast" as supported languages, where one name is a prefix of the other. --- src/modules/locale/LocaleConfiguration.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/modules/locale/LocaleConfiguration.cpp b/src/modules/locale/LocaleConfiguration.cpp index da8d4d0f3..f1810fb83 100644 --- a/src/modules/locale/LocaleConfiguration.cpp +++ b/src/modules/locale/LocaleConfiguration.cpp @@ -18,7 +18,11 @@ */ #include "LocaleConfiguration.h" + +#include "utils/Logger.h" + #include +#include LocaleConfiguration::LocaleConfiguration() : explicit_lang( false ) @@ -53,14 +57,9 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale, { QString language = languageLocale.split( '_' ).first(); - QStringList linesForLanguage; - for ( const QString& line : availableLocales ) - { - if ( line.startsWith( language ) ) - { - linesForLanguage.append( line ); - } - } + // Either an exact match, or the whole language part matches + // (followed by . or _ + QStringList linesForLanguage = availableLocales.filter( QRegularExpression( language + "[._]" ) ); QString lang; if ( linesForLanguage.length() == 0 || languageLocale.isEmpty() )