summaryrefslogtreecommitdiffstats
path: root/src/corelib/text
diff options
context:
space:
mode:
authorMate Barany <mate.barany@qt.io>2023-01-31 14:48:27 +0100
committerMate Barany <mate.barany@qt.io>2023-02-06 12:22:11 +0100
commit916008a50d88e19907e4e6aec921efd801818a00 (patch)
treee191c9755262fba4c6dcc5764a377f7fc75e0c3c /src/corelib/text
parent94c16517b3f8f01309a89598e698931ef77d60db (diff)
Include QLocale::system() in matchingLocales() return list
QLocale::matchingLocales() only returns matches from the CLDR database, it does not include the current system locale as a match, even if it does match. Add the current system locale, if it matches. Task-number: QTBUG-106644 Change-Id: If2e409bf0fd8582941646838330e36b79952d3f6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/text')
-rw-r--r--src/corelib/text/qlocale.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index efd6003d42..7392c50d50 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -2748,6 +2748,15 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language, QLocale::Scr
++index;
}
+ // Add current system locale, if it matches
+ const auto syslocaledata = systemData();
+
+ if (filter.acceptLanguage(syslocaledata->m_language_id)) {
+ const QLocaleId id = syslocaledata->id();
+ if (filter.acceptScriptTerritory(id))
+ result.append(QLocale::system());
+ }
+
return result;
}