Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

The ts files of qtlinguist are not created in cmake



  • Hello, I want to create the ts files to translate using qtlinguist and i use a cmake file to set up my project and i would like to add the code in the cmake to obtain the ts files. I do not get any error but the ts are
    not created. I cannot even see the comments to see if if iterates through the loop.

    The code i use in the cmake is as follows:

        set(TS_FILES
             translateApptr_lang_sp.ts 
          translateApptr_lang_en.ts
         )
    
    foreach(_ts_file ${TS_FILES})
      add_custom_command(
    		   OUTPUT ${_ts_file}
    		   COMMAND ${Qt5_LUPDATE_EXECUTABLE} -recursive 
                          ${CMAKE_CURRENT_SOURCE_DIR} -ts ${_ts_file}
    		   COMMENT "Updating ${_ts_file}"
    		MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}
    		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}
    		VERBATIM
    	)
    
         endforeach()
    
          qt5_create_translation(qmFiles ${TS_FILES})
          ......
    

    I have tried all the possible variations removing the depends and the main dependency but there is
    no way to get those files.

    Thank you very much for your help. There are no errors. but the ts files are not created.

    Cheers



  • @zandarina said in The ts files of qtlinguist are not created in cmake:

    What I would like is to create them in the same cmake of my project

    That's what qt5_create_translation does.

    In your case qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} translateApptr_lang_sp.ts translateApptr_lang_en.ts)

    Now you just have to add ${QM_FILES} to the sources of your project (e.g. target_sources(MyApp PRIVATE ${QM_FILES}))





  • Hello, I already saw this example but they do the lupdate serparately of the cmake. They already
    have the ts files. What I would like is to create them in the same cmake of my project so that i do not have
    to run a qmake and a cmake.

    Thanks



  • @zandarina said in The ts files of qtlinguist are not created in cmake:

    What I would like is to create them in the same cmake of my project

    That's what qt5_create_translation does.

    In your case qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} translateApptr_lang_sp.ts translateApptr_lang_en.ts)

    Now you just have to add ${QM_FILES} to the sources of your project (e.g. target_sources(MyApp PRIVATE ${QM_FILES}))



  • Thank you it works !!


Log in to reply