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

Review QLocale::uiLanguages() sort order

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.9
    • Core: Locales (i18n)
    • None
    • All
    • 8

    Description

      Recent changes to QLocale::uiLanguages() leave me thinking that we can do better.

      If the backends provided fallbackUiLocaleName(), we could include that in the list even when it's not one QLocale understands (e.g. legacy tags get converted to canonical forms, but a translation or voice option might use that tag in its name, so be worth matching). It is, in any case, what every backend has: each currently passes a string to the QLocale constructor, so we could use this string as the fallback name. We could also map it to a a fallback UI locale-ID (without flattening that via likely subtag rules to the QLocale currently constructed from it).

      The massaging of entries in uiLanguages() inserts entries based on likely sub-tag rules. If the entry is a minimal form, all entries inferred from it appear before it; otherwise after, even if they are more specific than it. We should aim to consistently put more specific names (i.e. those with more tags) before less. We could do that as follows:

      • Compute the most specific using withLikelySubtagsAdded();
      • Compute its various shortenings, separated into those that do and don't expand back to the same via likely sub-tag rules;
      • If the name these are derived from (via an ID) isn't one of them, it remains before all of them;
      • Otherwise,
        • those more specific than it (i.e. with more non-zero tag-ID fields) go before it (assert: all of these expand back to the same);
        • those equally or less specific, that expand back to the same, follow it; and
        • any that don't expand back to the same go to the end of the list.

      At present, we also append shortenings of each entry, at the end of the list. Some of these might expand back, via likely sub-tag rules, to the same result. The above corrects this, putting them in the list in the group to which the original entry expands.

      At present we can get duplicate entries in the uiLanguages() list; it would be good to eliminate such duplicates.

      This would involve rewriting lots of tests, but mostly just reordering entries in test lists.

      Attachments

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

        Activity

          People

            Eddy Edward Welbourne
            Eddy Edward Welbourne
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes