PySide translations work just partially
-
Hi,
I've just migrated from PyQt to PySide and I'm now working with translations. With PyQt the translations worked perfectly, but now with PySide there're some texts that aren't translated. I'm very confused, as I think I'm handling all the texts the same way.
What I've done so far:
Changed the string formatting from PyQt format "Hello %1" to PySide format "Hello {0}"
Deleted old .ts translation files (lupdate had some problems, better to start from scratch)
Generated new .ts files with command
@C:\Python27\Lib\site-packages\PySide\pyside-lupdate.exe Ui_MainWindow.py MainWindow.py -ts translations\German.ts@
Translated all texts using Qt Linguist and marked the texts "ready"
Compiled .qm files with command
@C:\Python27\Lib\site-packages\PySide\lrelease.exe translations\German.ts@
After this most of the translations are working, e.g.
@self.loggedStatus.setText(self.tr('User: {0}').format(self.user.name))@
...but in the same file the following text is not translated
@reply = QMessageBox.question(self, self.tr('Quit program'),
self.tr('Exiting program. Do you want to save the changes to report data?'),
QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)@When I look into .ts files, I see that both these texts are translated and their translation status is the same. I'd be very happy for any clues about what's going on here. :)
Thanks!
My configuration:
- Windows 7 (64 bit)
- Python 2.7.3 (32 bit)
- PySide 1.1.2 (32 bit)
-
Yay! I finally managed to find the reason for the problem. Using a python multi-line text without indentation confuses the Qt translation system so that the following translations won't work. E.g.
@def some_method(self):
self.tr('This text gets translated correctly')def get_info(self):
info_text = """<h1> My Program v. 1.0 </h1>
<br>
<br>
This multi-line text is not meant to be translated, but it breaks the translations from the following tr() calls.
"""
return info_textdef another_method(self):
self.tr('This text is not translated anymore because of the mutli-line text in method get_info.')
@Should I add this issue to PySide bug tracker? (I don't have bug tracker account yet).