qt6-bb10/tests/auto/corelib
Volker Hilsheimer 8352306cdc QTranslator: fix loading order when loading from locale
A locale's UI language includes the script, e.g. the QLocale::uiLanguage
list for the Australian locale en_AU is {"en_Latn_AU", "en_AU", "en"}.
The old code iterated over each language in the outer loop, and for each
language tried several times, removing a segment from the back with each
try in the inner loop. The de-facto search order was then

en_Latn_AU
en_latn_au
en_Latn
en_latn
en
en_AU
en_au
en

Usually, translation files are provided for country_Territory, i.e.
en_AU. But if an en file (for a generic English translation) was also
present, then en_AU was never tried.

Fix this by breaking the logic into two loops: first, create a list of
candidates by removing segments from each UI Language. Then sort that
list of candidates so that entries with more segments come first. The
search order is now:

en_Latn_AU
en_latn_au
en_Latn
en_latn
en_AU
en_au
en

This way, en_AU gets loaded correctly, before en is tried.

Adjust the test, which was essentially duplicating the logic from
QTranslator to generate files. This only tested that two identical loops
result in the same thing. Instead of using the system locale, make the
test data-driven, and explicitly try en_US and en_AU, with candidate
files generated based on a hardcoded list for each data row.

Pick-to: 6.7 6.5
Fixes: QTBUG-124898
Change-Id: I6bdcff289d2843e61c9053c116e955b79e09e95a
Reviewed-by: Mate Barany <mate.barany@qt.io>
(cherry picked from commit 9a11273b745a30cebb5cd648c89eb224e9704492)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 19:30:33 +00:00
..
animation Change license for tests files 2024-02-04 09:56:42 +01:00
global tst_QGlobal: fix -Wmaybe-uninitialized 2024-06-18 08:09:17 +00:00
io Handle VxWorks in QFileSelector 2024-06-19 14:02:58 +00:00
ipc tests: skip tst_QSharedMemory::useTooMuchMemory() on Linux arm64 2024-06-13 20:35:08 +00:00
itemmodels tst_QAbstractProxyModel: port to QTEST_THROW_ON_FAIL 2024-06-19 23:31:58 +00:00
kernel QTranslator: fix loading order when loading from locale 2024-06-20 19:30:33 +00:00
mimetypes QMimeType: use modernize comparisons 2024-04-30 17:46:34 +02:00
platform tst_qcomobject: Reduce size of Qt-namespace 2024-05-13 15:25:36 +02:00
plugin tst_QPlugin: Be specific when looking for plugins 2024-06-18 09:28:46 +00:00
serialization tst_QCborValue: port to QTEST_THROW_ON_FAIL 2024-06-19 23:31:45 +00:00
text tst_QRegularExpression: port to QTEST_THROW_ON_FAIL 2024-06-19 23:32:05 +00:00
thread tst_qfuture::signalConnect: Fix failure condition for MSVC 2024-06-20 19:30:11 +00:00
time Update CLDR Windows timezone data to v44.1 2024-06-02 15:25:00 +02:00
tools tst_QSharedPointer: check QWeakPointer vs. virtual bases 2024-06-20 19:05:31 +00:00
CMakeLists.txt tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00