Search code examples
pythonpyside6pyqt6

Pyside6 lupdate won't recognise marker "translate", only "tr"


I used pyside6 to develop a software, I'm trying to do i18n on it. I found a weird problem with the pyside6-lupdate tool.

When I use the 'tr' marker in my python file, the tool can successfully exact it to a ts file. i.e main.py

self.btn_open_file = QPushButton(self.tr('Open File Folder'), self)

the command I run in the terminal is:

pyside6-lupdate main.py -ts test.ts

But when I use it on QT designer generated python files, it won't work anymore, as those files use 'translate' as the marker, shown as below: ui_peg_page.py

def retranslateUi(self, PegPage):
        PegPage.setWindowTitle(QCoreApplication.translate("PegPage", u"Form", None))
        self.label.setText(QCoreApplication.translate("PegPage", u"1. Peg to Existing Mapping Column (OR)", None))
        self.label_2.setText(QCoreApplication.translate("PegPage", u"2. Create a New Mapping Column", None))
        self.groupBox.setTitle(QCoreApplication.translate("PegPage", u"GroupBox", None)

When I run the command again, nothing was extracted. I wonder if anyone has encountered the same issue before. My pyside6 version is 6.2.2.1. I tried this on both mac and windows, both won't work. Would appreciate it much if anyone can point me a way out.


Solution

  • As you use Qt Designer for UI creation you should provide lupdate with form file, not a generated python module.

    See details in PYSIDE-1717 and PYSIDE-1774.