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

QMimeType::comment() will miss translations from later providers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.9
    • Core: Locales (i18n)
    • None
    • All
    • 5

    Description

      QMimeTypePrivate::localeComment() contains the astute observation:

      maybe we want to merge in comments from more global providers, in
      case of more translations?


      to which I find the answer is "definitely, yes."
      This is the middle step in a double traversal: its caller, QMimeType::comment(), has a list of locales to traverse, while localeComment() has a list of providers to traverse. Each provider effectively provides this double traversal with a double-mapping: a mapping from MIME type name to (a struct with a member that give us) a mapping from locale names to localised full names for that MIME type. What we want is a localised full name of the MIME type for the earliest entry in the locale list for which some provider offers such a name.

      What we actually do at present is get, from QMimeTypePrivate::localeComment(), the mapping from locales to full names from the first provider that has anything for the given MIME type. Later providers may cover more locales for that MIME type, not covered by this first, but we do not consult them. If the first does not have a translation for some full name, but some later provider does, we'll only see the first's lack, not what the later provider offers. As a result, we may end up falling back to a later entry in the locale-name list or even falling off the end of that list and resorting to using the untranslated name, despite the presence of perfectly good translations, from other providers, for a locale early in the locale list.

      I propose that we change QMimeTypePrivate::localeComment() to take a language name (or the special key "default") and return the full name in that language for the MIME type named by the first parameter. (Renaming that first parameter from name to mimetype would also be a good idea, to tell the reader what we're doing.) It can return a null QString on failure.

      This would let the caller, QMimeType::comment(), ask for the "default" entry, do its new (post-Tika; see QTBUG-127004) translation attempt and then, on failure, iterate the QLocale::uiLanguages() list with calls to localeComment() for each entry in the language list, always getting the name from the first provider to provide one for the given language even if an earlier provider provides data for other languages.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-132895
          # Subject Branch Project Status CR V

          Activity

            People

              cnn Qt Core & Network
              Eddy Edward Welbourne
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change