Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-129434

[[Regr: 6.7.2 -> 6.7.3]] QTranslator::load finds languages in wrong order

    XMLWordPrintable

Details

    • macOS
    • f3fc7b210 (6.8.0), a30c1bcd3 (dev), e5c1d02ac (6.8), 313b0ae8c (tqtc/lts-6.5), 595f2126f (tqtc/lts-6.5.7), 8230c7d7a (dev), 6a785ce90 (dev), 1f2ab4674 (dev), fbdeec709 (6.8), c9d31c70d (6.8), 34a41d83d (6.8), fcc19fb4b (tqtc/lts-6.5), 84afaafc9 (dev)

    Description

      The latest Qt 6.7.3 introduced a different and wrong behaviour when loading translations from a folder using QTranslator::load with a QLocale.

      On my system I have multiple languages installed in the following order

      1. English
      2. German
      3. Traditional Chinese
      4. Simplified Chinese

      and the selected region is Germany.

      In my application I distribute language files with only the language codes like `en.qm`, `de.qm` but also `zh_Hans` or `zh_Hant` for more granular specialization.

      When loading translations from a folder based on the system QLocale, the logic to find the best matching language now does not respect the system's language order anymore, hence the most concrete language found will be applied, which will be any of the Chinese in my example as they also define the script.

      A quick analysis in the code shows that the language file candidates are checked from most specific to least specific, resulting in a list like:

      • en_Latn_DE
      • ...
      • zh_Hant_DE
      • en_Latn
      • zh_Hant
      • ...
      • en
      • zh

      Following this precedence it will prefer Chinese over English, as language_script is ranked higher than pure language codes, which totally ignore the system language order.

      The previous versions and my expected result is to check in system order to find in this case English over Chinese.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity