Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. CMake based app with translation files
Qt 6.11 is out! See what's new in the release blog

CMake based app with translation files

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
1 Posts 1 Posters 521 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.
  • A Offline
    A Offline
    aatwo
    wrote on last edited by
    #1

    Hi all. I have a cmake based project I am testing out translation files with.

    I am using the following CMake code to compile and copy my .ts tranlsation files to my build folder in .qm form.

    set(TRANSLATION_FILES
        translations/ui/translation-english.ts
        translations/ui/translation-french.ts
    )
    set_source_files_properties(${TRANSLATION_FILES} PROPERTIES OUTPUT_LOCATION "translations/ui")
    qt5_add_translation(QM_FILES ${TRANSLATION_FILES})
    
    ...
    
    add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${HEADERS} ${QM_FILES})
    

    This was strung together using the example code from here: https://doc.qt.io/qt-5/qtlinguist-cmake-qt5-add-translation.html) and works great when building from within Qt Creator and the files are placed here:

    <app-exe-output-folder>/tranlsations/ui/
    

    However, when building from within Visual Studio the build goes into a Release subfolder while my .qm translation files do not. So it looks something like this...

    <output-folder>/tranlsations/ui/tranlsation-english.qm
    <output-folder>/tranlsations/ui/tranlsation-french.qm
    <output-folder>/Release/MyApp.exe
    

    Is it possible for the Visual studio build to drop the qm files into the Release subfolder without breaking the Qt creator build?

    I.e. the following structure instead:

    <output-folder>/Release/tranlsations/ui/tranlsation-english.qm
    <output-folder>/Release/tranlsations/ui/tranlsation-french.qm
    <output-folder>/Release/MyApp.exe
    
    1 Reply Last reply
    0

    • Login

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