diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-04-06 13:16:35 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-06-07 17:14:14 +0200 |
commit | cce3445e70ff98e55475c544c43177c2cd4a1034 (patch) | |
tree | e9c6d92b2c930fe93921a2cae6a94c4a4922a460 /src/corelib/text/qlocale.cpp | |
parent | b2871765ced8059e571d17d4010e8d8ada4e9190 (diff) |
Always include standard name in QLocale::uiLanguages()
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 <qt_ci_bot@qt-project.org>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/text/qlocale.cpp')
-rw-r--r-- | src/corelib/text/qlocale.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
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. |