Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: PyQt and i18n, only "half of it" is translated

  1. #1
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default PyQt and i18n, only "half of it" is translated

    Hi,

    i wrote a project in pyqt and wanted to let it do i18n now. so i wrapped all my texts in self.tr() and wrote a .pro file like this:
    Qt Code:
    1. SOURCES = main.py models.py
    2. FORMS = ui/beans.ui ui/blends.ui ui/edit.ui ui/mainWindow.ui ui/profile.ui ui/roast.ui ui/select.ui ui/settings.ui ui/temptime.ui
    3. TRANSLATIONS = roasterbase_de.ts
    To copy to clipboard, switch view to plain text mode 

    then i did a pylupdate4 on that pro-file and translated everything in linguist. ran lrelease on the pro file and it says that ~140 finished entries are there. now i installed a translator onto my QApplication:
    Qt Code:
    1. app = QtGui.QApplication(sys.argv)
    2.  
    3. translator = QTranslator()
    4. print translator.load("roasterbase_de.qm", ".")
    5.  
    6. app.installTranslator(translator)
    To copy to clipboard, switch view to plain text mode 

    load() returns true. Thing is, only half of the stuff is translated, only a few dialogs but not all and some table headings - but again not all...

    where could i start looking for the error?

    Thanks in advance
    - Dario

    PS: the project is available on svn://ghostdub.de/roasterbase

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    Do these untranslated strings come from your code or are part of Qt?

  3. #3
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    Partially from my code an partially from the pyuic4 converted qt-designer files...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    Check if you don't have more than one roasterbase_de.qm file, delete all of them and run lrelease once more.

    Could post the location in your code where such untranslated string appears?

  5. #5
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    Example would be all strings from beans.py (created from ui/beans.ui).

    Just deleted the .qm and retranslated everything, still the same :/.

    thanks for the help so far!
    - Dario

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PyQt and i18n, only "half of it" is translated

    Please post the example code, not the repository address.

  7. #7
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    Hi,

    i somehow resisted to post two such long files ... also the BBS didnt allow me to post them, so i nopasted them. How i install the QTranslator is in my first post. Here the files, ui and pyuic4 generated:
    http://rafb.net/p/HfZ0sF93.html
    http://rafb.net/p/9fI0ir88.html

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PyQt and i18n, only "half of it" is translated

    Couldn't you have just pasted the parts of the files that are relevant to the problem?

    BTW. I don't think that ui files or autogenerated files will get us anywhere... We can assume they are ok.

  9. #9
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    Well, what code should i post then? Its mainly the Strings from the pyuic generated files.

    Another example would be main.py 365,
    Qt Code:
    1. self.fcMarker1 = Qwt.QwtPlotMarker()
    2. [...]
    3. label = self.fcMarker1.label()
    4. label.setText(self.tr('first Crack'))
    To copy to clipboard, switch view to plain text mode 

    where the last line is 365. 'first Crack' is transted to "Erstes Knacken" in linguist, howver "first Crack" still shows up. On the other hand all headers in models.py are translated:
    Qt Code:
    1. def headerData(self, section, orientation, role):
    2. if role==0 and orientation==1:
    3. if section==0:
    4. return QtCore.QVariant(self.tr("Name"))
    5. elif section==1:
    6. return QtCore.QVariant(self.tr("Country"))
    7. elif section==2:
    8. return QtCore.QVariant(self.tr("Stock"))
    9. return QtCore.QVariant()
    To copy to clipboard, switch view to plain text mode 

    ALL strings from uic-generated files aren't translated except temptime.[py,ui] - if i only knew whats different with this one...

    thanks again so far :P
    - Dario

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PyQt and i18n, only "half of it" is translated

    Check if the .ts files contain correct translations and if the strings are marked as translated.

  11. #11
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    Everything alright on that side - or at least it looks to me like it is. I nopasted the .ts file, so maybe someone could doublecheck: http://rafb.net/p/wHxClu46.txt

    Thanks once again :P
    - Dario

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    What happens if you change one of the working translations and regenerate the .qm file? Can you see the change in your application?

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PyQt and i18n, only "half of it" is translated

    Quote Originally Posted by NebuK View Post
    I nopasted the .ts file, so maybe someone could doublecheck
    And why not use the attachment feature from this forum?

  14. #14
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    Heho,

    just tried, changes are visible...

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    What happens if you change labels for downButton and upButton in beans.ui to "down" and "up" (or similar)?

  16. #16
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    Hi,

    also no luck with that, those unicode-chars dont seem to do any harm.

    greeting
    - dario

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PyQt and i18n, only "half of it" is translated

    Try deleting all intermediate files (.pyc included) and rebuild the project.

  18. #18
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    i do that everytime i try ...

    i also tried again with using both, the uic generated files in SOURCES= and the .ui files in FORMS=. Another thing i tried is letting the classes generated by pyuic4 be inherited from QObject and using self.tr instead of the QtGui.QApplication.translate provided by pyuic ... doesnt work too :/.
    Last edited by NebuK; 22nd January 2008 at 11:18.

  19. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PyQt and i18n, only "half of it" is translated

    Could you see if the problem is persistent across applications? I mean if the same happens for a clean simple and small application written from scratch.

  20. #20
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt and i18n, only "half of it" is translated

    Just created a mainwindow with only 2 labels, one set from the source, and one set from the ui file. i then again tried both, including the .ui or the uic4-generated .py in the .pro and translating. Didnt work - only the label i set from source worked, ui didnt.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.