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

lupdate interprets "\n" differently in C++ and QML translation comments

    XMLWordPrintable

Details

    Description

      lupdate behaves differently when encountering the escape sequence \n in translation comments in C++ or QML.

      For example, the QML

      foo.qml
      import QtQuick 2.6
      
      Item {
          /*% "Test\ntext"
           */
          /*: Some translation comment\n
              with line break.
           */
          property string dummyText: qsTrId("myTextId")
      }
      

      produces a message in the .ts file like this:

      <message id="myTextId">
          <source>Test\ntext</source>
          <extracomment>Some translation comment\n with line break.</extracomment>
          <translation type="unfinished"></translation>
      </message>
      

      So the \n are not interpreted but taken literally.

      While the same translation comment in C++

      foo.cpp
      /*% "Test\ntext"
       */
      /*: Some translation comment\n
          with line break.
       */
      static QString myText = qtTrId("myTextId");
      

      produces a message like this:

      <message id="myTextId">
          <source>Test
      text</source>
          <extracomment>Some translation comment
       with line break.</extracomment>
          <translation type="unfinished"></translation>
      </message>
      

      So the \n are converted to line breaks.

      Steps to reproduce:

      • Run lupdate on the above given foo.qml or foo.cpp:
        lupdate foo.qml -ts foo-qml.ts
        lupdate foo.cpp -ts foo-cpp.ts
        

      Expected Behavior:

      Identical translation comments should produce the same message in the .ts files.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kkohne Kai Köhne
              ignitor Jochen Ulrich
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes