Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Empty .ts files after lupdate (CMake and macOS 6.3.2)

Empty .ts files after lupdate (CMake and macOS 6.3.2)

Scheduled Pinned Locked Moved Unsolved General and Desktop
lupdatetranslation
4 Posts 2 Posters 760 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sikarjan 0
    wrote on 20 Sept 2022, 17:45 last edited by
    #1

    Hi there!

    I need help again here because I was not able to find a solution on the web. I do not manage to get a translation file. Here is minimal example:

    Created a new project "Qt Widget Application"
    Choose CMake
    Selected Qt 6.3.2 for macOS as kit
    Selected a language (English)
    Created the project.

    Add a label to the design file with "Test Label" as text.
    Add QObject::tr("Test String"); to mainwindow.cpp

    When I run the project it compiles.
    Running lupdate from Qt Creator:

    lupdate warning: no TS files specified. Only diagnostics will be produced.
    

    CMakeLists.txt was generated by Qt Creator and includes:

    set(TS_FILES Test_en_GB.ts)
    
    set(PROJECT_SOURCES
            main.cpp
            mainwindow.cpp
            mainwindow.h
            mainwindow.ui
            ${TS_FILES}
    )
    

    Is there a bug in the CMake create process? Do I need to do something extra? In one tutorial I saw that they added some lines to copy qm files. Is that missing?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on 20 Sept 2022, 20:27 last edited by
      #2

      https://doc.qt.io/qt-6/qtlinguist-cmake-qt-add-translations.html#qt6-add-translations

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sikarjan 0
        wrote on 20 Sept 2022, 21:54 last edited by
        #3

        Thanks for the link but it does not really help me. It does not say but I am assuming they are talking about the CMakeListe.txt, correct?
        Here is my full CmakeList after editing:

        cmake_minimum_required(VERSION 3.5)
        
        project(ncNotes VERSION 0.1 LANGUAGES CXX)
        
        set(CMAKE_INCLUDE_CURRENT_DIR ON)
        
        set(CMAKE_AUTOUIC ON)
        set(CMAKE_AUTOMOC ON)
        set(CMAKE_AUTORCC ON)
        
        set(CMAKE_CXX_STANDARD 17)
        set(CMAKE_CXX_STANDARD_REQUIRED ON)
        
        find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
        find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
        
        set(TS_FILES ncNotes_en_EN.ts
                ncNotes_de_DE.ts)
        
        set(PROJECT_SOURCES
                main.cpp
                mainwindow.cpp
                mainwindow.h
                notemodel.cpp
                notemodel.h
                mainwindow.ui
                infoDialog.ui
                ${TS_FILES}
        )
        
        if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
            qt_add_executable(ncNotes
                MANUAL_FINALIZATION
                ${PROJECT_SOURCES}
            )
            qt6_add_translations(ncNotes TS_FILES ncNotes_de_DE.ts) // added this line
        # Define target properties for Android with Qt 6 as:
        #    set_property(TARGET ncNotes APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
        #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
        # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
        
        #    qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) // commented this out because it caused an error (see below)
        else()
            if(ANDROID)
                add_library(ncNotes SHARED
                    ${PROJECT_SOURCES}
                )
        # Define properties for Android with Qt 5 after find_package() calls as:
        #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
            else()
                add_executable(ncNotes
                    ${PROJECT_SOURCES}
                )
            endif()
        
            qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
        endif()
        
        target_link_libraries(ncNotes PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
        
        set_target_properties(ncNotes PROPERTIES
            MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
            MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
            MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
            MACOSX_BUNDLE TRUE
            WIN32_EXECUTABLE TRUE
        )
        
        install(TARGETS ncNotes
            BUNDLE DESTINATION .
            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
        
        if(QT_VERSION_MAJOR EQUAL 6)
            qt_finalize_executable(ncNotes)
        endif()
        
        

        Error Message:

          Attempt to add a custom rule to output
        
            /Users/xxx/ncNotes/build-ncNotes-Qt_6_3_2_for_macOS-Debug/ncNotes_de_DE.qm.rule
        
          which already has a custom rule.
        

        Is there a little more documentation or an example that could help understanding this?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sikarjan 0
          wrote on 21 Sept 2022, 10:14 last edited by
          #4

          I just redid the project with qmake an here everything works out of the box. Also adding an icon, which I was not able to do with the official documentation.

          So I expect there is something wrong with the creation process of CMakeListe.txt?

          1 Reply Last reply
          0

          2/4

          20 Sept 2022, 20:27

          • Login

          • Login or register to search.
          2 out of 4
          • First post
            2/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved