Results 1 to 2 of 2

Thread: Encoding problem - QObject::tr doesn't translate sentences with accents

  1. #1
    Join Date
    Mar 2013
    Posts
    11
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Encoding problem - QObject::tr doesn't translate sentences with accents

    Hello,

    I'm using Qt 5.0.1 for my project. Every source code is written in French, and I want to translate it in English. With the prior version of Qt (4.x), I used to translate my program with no problems. But now with Qt 5, sentences with accents are not translated anymore.

    I know Qt5 expects the source code to be written with UTF-8. Then I upgraded to Qt5, I changed the encoding of my files to UTF-8. So every header and source file is in UTF-8. I read on the Internet that one should add CODECFORTR = UTF-8 in their .pro file. Whether I do it or not, I still have the same issue.

    Here is a piece of source code:


    And here is how I see it in Qt Linguist:

    We can notice that
    Qt Code:
    1. QAction *fSaveMass = file->addAction(tr("Enregistrer sous différentes teintes"));
    To copy to clipboard, switch view to plain text mode 
    has become in Qt Linguist
    Qt Code:
    1. QAction *fSaveMass = file->addAction(tr("Enregistrer sous différentes teintes"));
    To copy to clipboard, switch view to plain text mode 
    which means that Qt Linguist opens it thinking it's a latin encoding, while it's utf-8. But on the left and bottom side of Qt Linguist, it got the source code right: it's written "différentes" with the right encoding :s.

    I think that's why my sentences with accents are not translated (the rest works fine). Does someone have any idea?

    Thank you very much!

    Regards,
    Sébastien.

  2. #2
    Join Date
    Mar 2013
    Posts
    11
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Encoding problem - QObject::tr doesn't translate sentences with accents

    Hello everyone!

    I solved the problem. I post here in case someone has the issue. It seems to be a glitch of QtLinguist. The only thing I was doing wrong was to release the qm files with Qt Linguist. If I release them with lrelease.exe, then it works as expected, sentences with accents are translated !

    So don't release with Qt Linguist...

Similar Threads

  1. QGraphicsItem doesn't inherit QObject?
    By xyzt in forum Qt Programming
    Replies: 6
    Last Post: 26th September 2011, 14:59
  2. Problem with translate one element
    By Hostel in forum Newbie
    Replies: 0
    Last Post: 19th November 2010, 00:00
  3. The header file 'mainwindow.h' doesn't include <QObject>.
    By nhs_0702 in forum Qt Programming
    Replies: 5
    Last Post: 14th May 2010, 17:02
  4. problem with accents
    By mmm286 in forum Qt Programming
    Replies: 4
    Last Post: 5th August 2009, 18:17
  5. Problem with windows and accents
    By esterbonmati in forum Qt Programming
    Replies: 0
    Last Post: 11th February 2009, 10:00

Tags for this Thread

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.