diff options
-rw-r--r-- | src/corelib/text/qlocale.cpp | 20 | ||||
-rw-r--r-- | src/corelib/text/qlocale_data_p.h | 3 | ||||
-rw-r--r-- | tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 2 | ||||
-rw-r--r-- | util/locale_database/cldr.py | 2 | ||||
-rw-r--r-- | util/locale_database/qlocalexml.py | 2 |
5 files changed, 15 insertions, 14 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 42fdb49474e..6757c4bf0b7 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -390,15 +390,17 @@ QLocaleId QLocaleId::withLikelySubtagsAdded() const noexcept return value; } } - if (matchesAll()) { // Skipped all of the above. - // CLDR has no match-all at v37, but might get one some day ... - pairs = std::lower_bound(pairs, afterPairs, sought); - if (pairs < afterPairs) { - // All other keys are < match-all. - Q_ASSERT(pairs + 1 == afterPairs); - Q_ASSERT(pairs->key.matchesAll()); - return pairs->value; - } + // Finally, fall back to the match-all rule (if there is one): + pairs = afterPairs - 1; // All other keys are < match-all. + if (pairs->key.matchesAll()) { + QLocaleId value = pairs->value; + if (language_id) + value.language_id = language_id; + if (territory_id) + value.territory_id = territory_id; + if (script_id) + value.script_id = script_id; + return value; } return *this; } diff --git a/src/corelib/text/qlocale_data_p.h b/src/corelib/text/qlocale_data_p.h index 7eb88d61941..08b891eea66 100644 --- a/src/corelib/text/qlocale_data_p.h +++ b/src/corelib/text/qlocale_data_p.h @@ -59,7 +59,7 @@ struct LanguageCodeEntry // GENERATED PART STARTS HERE /* - This part of the file was generated on 2024-10-09 from the + This part of the file was generated on 2024-12-02 from the Common Locale Data Repository v45 http://www.unicode.org/cldr/ @@ -1031,6 +1031,7 @@ static inline constexpr QLocaleId likely_subtags[] = { { 0, 139, 0 }, { 308, 139, 134 }, // und_Vaii -> vai_Vaii_LR { 0, 141, 0 }, { 255, 141, 50 }, // und_Yiii -> ii_Yiii_CN { 0, 142, 0 }, { 339, 142, 161 }, // und_Rohg -> rhg_Rohg_MM + { 0, 0, 0 }, { 75, 66, 248 }, // und -> en_Latn_US }; static inline constexpr quint16 locale_index[] = { diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index fba1fd01437..c1db299348e 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -429,7 +429,7 @@ void tst_QLocale::defaulted_ctor() QCOMPARE(l.territory(), exp_country); \ } while (false) - TEST_CTOR(AnyLanguage, AnyTerritory, defaultLanguage, defaultTerritory); + TEST_CTOR(AnyLanguage, AnyTerritory, QLocale::English, QLocale::UnitedStates); TEST_CTOR(C, AnyTerritory, QLocale::C, QLocale::AnyTerritory); TEST_CTOR(Aymara, AnyTerritory, defaultLanguage, defaultTerritory); TEST_CTOR(Aymara, France, defaultLanguage, defaultTerritory); diff --git a/util/locale_database/cldr.py b/util/locale_database/cldr.py index 0e5154b8b57..c2b8611e6d3 100644 --- a/util/locale_database/cldr.py +++ b/util/locale_database/cldr.py @@ -62,8 +62,6 @@ class CldrReader (object): else: self.grumble(f'Skipping likelySubtag "{got}" -> "{use}" ({e})\n') continue - if not any(have): - continue give = (give[0], # Substitute according to http://www.unicode.org/reports/tr35/#Likely_Subtags diff --git a/util/locale_database/qlocalexml.py b/util/locale_database/qlocalexml.py index 3d950c3af33..92996ca48fb 100644 --- a/util/locale_database/qlocalexml.py +++ b/util/locale_database/qlocalexml.py @@ -281,7 +281,7 @@ class QLocaleXmlReader (object): sub-tags mapping says language's default locale uses the given script and territory.""" for have, give in self.__likely: - if have[1:] == (0, 0) and give[2]: + if have[0] and have[1:] == (0, 0) and give[2]: assert have[0] == give[0], (have, give) yield (give[:2], give[2]) |