-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.8 6.7 6.5 Fixes: QTBUG-124898 Change-Id: I6bdcff289d2843e61c9053c116e955b79e09e95a Reviewed-by: Mate Barany <mate.barany@qt.io>
- Loading branch information
Showing
2 changed files
with
55 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters