Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2863

pyside6-lupdate do not attribute comment to corresponding text

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.8.1, 6.5.7
    • 6.7.2
    • Tooling
    • None
    • Linux/X11
    • 0eac22580 (dev), b0d62bb7f (6.8), b6843c621 (6.7), a5302e48b (tqtc/lts-6.5)

    Description

      When using pyside6-lupdate, comments for translation are not in the correct translation unit in the resulting translation file. Note that the source file line number of the text to translate is also incorrect.

      The current workaround found is to add a python statement between the two translation but such coding rules is hard to justify and enforce. No workaround has been found that do not modify source code (lupdate tools option or else).

       

      reproducer.py:

      from PySide6 import QtWidgetsif __name__ == "__main__":
        firstText = QtWidgets.QApplication.translate('test', 'First text')
        #: This is a comment for the second text
        secondText = QtWidgets.QApplication.translate('test', 'Second text') 

      Command line used to generate translation file:

      pyside6-lupdate reproducer.py -ts translation.po 

      Output of the command:

      Updating 'translation.po'...
          Found 2 source text(s) (2 new and 0 already existing)

       

      Resulting translation.po with the comment one the wrong translation unit:

      msgid ""
      msgstr ""
      "MIME-Version: 1.0\n"
      "Content-Type: text/plain; charset=UTF-8\n"
      "Content-Transfer-Encoding: 8bit\n"
      "X-Qt-Contexts: true\n"
      
      #. This is a comment for the second text
      #: /home/user/reproducer.py:6
      msgctxt "test|" 
      msgid "First text"
      msgstr ""
      
      #: /home/user/reproducer.py:7
      msgctxt "test|"
      msgid "Second text"
      msgstr ""
      

       

       

      Attachments

        1. pyside2863_diag.diff
          8 kB
        2. pyside2863_log.txt
          5 kB
        3. pyside2863.py
          0.2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            mathieualbi Mathieu Albi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews