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

qt6_add_translations() deletes CMake-generated *.ts files when project is cleaned

    XMLWordPrintable

Details

    • 2e1b52671 (dev), 72cdabcb6 (6.6), 15ef5042d (6.5)

    Description

      If a *.ts file in qt6_add_translations() does not exist, the build system kindly offers to auto-generate it:

      CMake Warning at C:/Qt/6.4.0/msvc2019_64/lib/cmake/Qt6LinguistTools/Qt6LinguistToolsMacros.cmake:241 (message):
        Translation file
        'C:/Qt/Examples/Qt-6.4.0/linguist/hellotr/hellotr_la.ts' does not
        exist.  Consider building the target 'hellotr_lupdate' to create an initial
        version of that file.
      

      Unfortunately, auto-generated files also get auto-deleted. 

       

      Steps to reproduce

      1. In Qt Creator, load the CMakeLists.txt file for the Hello tr() Example (https://doc.qt.io/qt-6/qtlinguist-hellotr-example.html ).
      2. Build the `update translations` target to auto-generate hellotr_la.ts.
      3. Use Qt Linguist to translate hellotr_la.ts
      4. Build the `hellotr` target and run the executable to confirm that the translation is applied correctly
      5. In Qt Creator, click "Build" > "Clean"

       

      Actual Outcome

      At the end of Step #5, hellotr_la.ts is deleted. The translator's work is lost.

       

      Expected Outcome

      At the end of Step #5, hellotr_la.ts and its contents are preserved.

       

      Workaround

      Ensure that all of your project's required *.ts files already exist prior to building your project for the first time. CMake ... --target clean won't delete files that CMake did not generate.

      Attachments

        Issue Links

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

          Activity

            People

              jbornema Joerg Bornemann
              jksh Sze Howe Koh
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes