From cce3445e70ff98e55475c544c43177c2cd4a1034 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 6 Apr 2021 13:16:35 +0200 Subject: Always include standard name in QLocale::uiLanguages() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, for locales other than the system locale, no entry was added to the list for the actual locale whose variants - with and without likely sub-tags - were being appended. In most cases the standard name will in fact coincide with the variant without likely sub-tags, so this was unlikely to cause a problem, but it should be present regardless. At the same time, turn tst_QLocale::uiLanguages() into a data-driven test and add another row to its table. Change-Id: I5cb2d805d78fc3415d82b169caa6154b0f284708 Reviewed-by: Qt CI Bot Reviewed-by: MÃ¥rten Nordheim --- src/corelib/text/qlocale.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/corelib/text/qlocale.cpp') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 47fb6dcb9d..5f3e859667 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -4270,6 +4270,9 @@ QStringList QLocale::uiLanguages() const } for (int i = locales.size(); i-- > 0; ) { const QLocale &locale = locales.at(i); + const auto data = locale.d->m_data; + QLocaleId id = data->id(); + int j; QByteArray prior; if (i < uiLanguages.size()) { @@ -4278,13 +4281,18 @@ QStringList QLocale::uiLanguages() const prior = uiLanguages.at(i).toLatin1(); // Insert just after the entry we're supplementing: j = i + 1; + } else if (id.language_id == C) { + // Attempt no likely sub-tag amendments to C: + uiLanguages.append(locale.name()); + continue; } else { // Plain locale, not system locale; just append. + const QString name = locale.bcp47Name(); + uiLanguages.append(name); + prior = name.toLatin1(); j = uiLanguages.size(); } - const auto data = locale.d->m_data; - QLocaleId id = data->id(); const QLocaleId max = id.withLikelySubtagsAdded(); const QLocaleId min = max.withLikelySubtagsRemoved(); id.script_id = 0; // For re-use as script-less variant. -- cgit v1.2.3