Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
6.2.2
-
None
Description
Summary is in a subject line. More detailed example:
main.py - very simle file to display main window and assign text to a label:
from PySide6.QtWidgets import QApplication, QMainWindow from main_wnd import Ui_MainWindow class MainWnd(QMainWindow, Ui_MainWindow): def __init__(self): QMainWindow.__init__(self) self.setupUi(self) self.label.setText(self.tr("Test label")) def main(): app = QApplication() wnd = MainWnd() wnd.show() return app.exec() if __name__ == '__main__': main()
UI of main window is created as main_wnd.ui with help of Qt Designer (attached). This file was converted to main_wnd.py with help of command /usr/lib/qt6/uic -g python -o ./main_wnd.py ./main_wnd.ui. It contains a right block of code for UI translation:
def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Test phrase window", None)) self.label.setText(QCoreApplication.translate("MainWindow", u"TextLabel", None))
Then I created very simple main.pro file:
SOURCES = ./main.py ./main_wnd.py TRANSLATIONS = en.ts ru.ts
Next step is to generate translation files and here is the problem.
When I run command /usr/lib/qt6/bin/lupdate main.pro I get only this in ru.ts:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.1"> <context> <name>MainWnd</name> <message> <location filename="main.py" line="12"/> <source>Test label</source> <translation type="unfinished"></translation> </message> </context> </TS>
I.e. it takes only text from my own main.py module and ignores QCoreApplication.translate() calls generated by Qt Designer in main_wnd.py.
Old version of the tool (pylupdate5 main.pro) generates full set of tranlations - one line for main.py and two lines for main_wnd.py:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.1"> <context> <name>MainWindow</name> <message> <location filename="main_wnd.py" line="50"/> <source>Test phrase window</source> <translation type="unfinished"></translation> </message> <message> <location filename="main_wnd.py" line="51"/> <source>TextLabel</source> <translation type="unfinished"></translation> </message> </context> <context> <name>MainWnd</name> <message> <location filename="main.py" line="9"/> <source>Test label</source> <translation type="unfinished"></translation> </message> </context> </TS>
Attachments
Issue Links
- duplicates
-
PYSIDE-1717 pyside2-lupdate generated a blank .ts file
- Closed