Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-26193

qsTr() does not work with non-ASCII Latin-1 characters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.8.0, 4.8.2, 5.3.0 Beta1
    • None
    • Windows 7, mingw (problem also seen with MSVC2005)

    Description

      Non-ASCII Latin-1 characters are not handled properly by the qsTr() function.
      The attached example program shows that the correct translation ('good') is chosen by the C++ translate() function, whereas another translation ('bad') is chosen by the qsTr() function, regardless of where the string to translate comes from. With Qt 4.7.4 the correct translation ('good') is chosen by both translate() and qsTr().
      The translation string chosen by qsTr() was (erroneously) added to the .ts file by lupdate, and seems to be the result of a UTF-8 character sequence treated as Latin-1 and yet again transformed to UTF-8 (or something along those lines).
      To reproduce the problem, simple compile and run the example code and see that different translations ('good'/'bad') are chosen.
      The codecs for the source code files are the default ones, i.e. Latin-1 for the C++ files and UTF-8 for the QML file.

      Attachments

        1. TranslationTest.pro
          0.2 kB
        2. TranslationTest.qml
          0.2 kB
        3. TranslationTest_sv.qm
          0.1 kB
        4. TranslationTest_sv.ts
          0.6 kB
        5. main.cpp
          1 kB
        6. qml-translations.tar.bz2
          0.7 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kkohne Kai Köhne
            ludde Ludvig Borgne
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes