Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PySide translations work just partially
Forum Updated to NodeBB v4.3 + New Features

PySide translations work just partially

Scheduled Pinned Locked Moved Language Bindings
2 Posts 1 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jazuju
    wrote on last edited by
    #1

    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)
    1 Reply Last reply
    0
    • J Offline
      J Offline
      jazuju
      wrote on last edited by
      #2

      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_text

      def 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).

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved