[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.
This commit is contained in:
parent
49690fc681
commit
a09593e4a2
@ -18,7 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "LocaleConfiguration.h"
|
#include "LocaleConfiguration.h"
|
||||||
|
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
LocaleConfiguration::LocaleConfiguration()
|
LocaleConfiguration::LocaleConfiguration()
|
||||||
: explicit_lang( false )
|
: explicit_lang( false )
|
||||||
@ -53,14 +57,9 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
|
|||||||
{
|
{
|
||||||
QString language = languageLocale.split( '_' ).first();
|
QString language = languageLocale.split( '_' ).first();
|
||||||
|
|
||||||
QStringList linesForLanguage;
|
// Either an exact match, or the whole language part matches
|
||||||
for ( const QString& line : availableLocales )
|
// (followed by .<encoding> or _<country>
|
||||||
{
|
QStringList linesForLanguage = availableLocales.filter( QRegularExpression( language + "[._]" ) );
|
||||||
if ( line.startsWith( language ) )
|
|
||||||
{
|
|
||||||
linesForLanguage.append( line );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString lang;
|
QString lang;
|
||||||
if ( linesForLanguage.length() == 0 || languageLocale.isEmpty() )
|
if ( linesForLanguage.length() == 0 || languageLocale.isEmpty() )
|
||||||
|
Loading…
Reference in New Issue
Block a user