Details
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
For Gerrit Dashboard: PYSIDE-2863 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
591187,2 | lupdate/Python: Fix extra comments being added to the wrong message | dev | qt/qttools | Status: MERGED | +2 | 0 |
591255,2 | lupdate/Python: Fix extra comments being added to the wrong message | 6.8 | qt/qttools | Status: MERGED | +2 | 0 |
591258,2 | lupdate/Python: Fix extra comments being added to the wrong message | 6.7 | qt/qttools | Status: MERGED | +2 | 0 |
591288,2 | lupdate/Python: Fix extra comments being added to the wrong message | tqtc/lts-6.5 | qt/tqtc-qttools | Status: MERGED | +2 | 0 |