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

QMimeType comment property should return en_US comment when appropriate translation is empty.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 5.12.1
    • 5.11.2
    • Core: Other
    • None
    • Tested under Qt 5.10 and 5.11. See the description for detail.
    • Linux/X11
    • e3c84b6da1

    Description

      The comment property of QMimeType will use the default language (QLocale().name()) to select the appropriate translation (qt5.11:qmimetype.cpp#L261), Locale comments are load from QMimeDatabase via QMimeProvider and QMimeProvider will parse local shared mime info database (usually at /usr/share/mime/packages/ ) and treat the comment element as the locale value. Accroding to qt5.11 qmimeprovider.cpp#L504 we can see when there isn't a `xml:lang` set to the comment element (meant to be the default locale comment when no matched locale comment available), QMimeProvider will set a `en_US` language code for that locale comment.

      When the user's default language is not en_US (for example, zh_CN), and an application haven't provide a comment element with `xml:lang` set to zh_CN but only a default comment element is provided, QMimeType::comment() will return the mime name instead of the provided default comment since it simply can't find the zh_CN comment.

      Tested under Qt 5.10 and 5.11. This issue was firstly found with KDE's file manager Dolphin with a file with `application/wps-office.ppt` mimetype and with wps-office package installed.

      We can reproduce this issue with a sample shared mimetype database xml like this one (example: /usr/share/mime/packages/Qt-Bugreport-test.xml):

      <?xml version='1.0' encoding='utf-8'?>
      <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
      <mime-type type="application/qt-bugreport.bug">
      <comment>Qt bug report default comment</comment>
      <sub-class-of type="text/plain"/>
      <glob pattern="*.bug" weight="100"/>
      </mime-type>
      </mime-info>

      Then update mime database and create an empty sample file for test:

      sudo update-mime-database /usr/share/mime
      touch ~/test.bug

      Then when trying to get mime comment from `~/test.bug`, we'll get a"application/qt-bugreport.bug" string (the QMimeType::name() value) instead of the one which should be the default comment. The default comment is set as en_US locale comment (qt5.11 qmimeprovider.cpp#L504) so it should probably return the en_US comment if the user locale comment is empty but the en_US locale comment is not empty.

      I'm not sure if it's a bug or it's the designed behavior, so please correct me if I posted with the wrong issue type. Thanks.

      Attachments

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

        Activity

          People

            dfaure_kdab David Faure
            blumia Gary Wang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes