Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved How should I organise translations of plugins?

    General and Desktop
    plugin translation
    2
    4
    47
    Loading More Posts
    • 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.
    • O
      odelaune last edited by

      I am wondering what is the best way/the most clever way to organise the translation of plugins?

      There are two options:

      • option 1: one single file with the translations of the main application and the translations of all the plugins
      • option 2: one file with the translations of the main application and one translation file per plugin

      The option 2 seems more logical to me, because when I create new plugins for my main application, I ship the translation of that plugin inside my plugin. However, Qt Creator only uses one translation file for Qt Creator itself and all its plugins. I do not understand why this logic is used.

      So if the option 1 is preferred, how to create only one big TS file?
      My project has a source directory for the main application and the plugins sources are located in subdirectories.

      If the option 2 is preferred, how to write the plugin CMakeLists to handle the translations? Is there something specific with the plugin translations?

      Christian Ehrlicher 1 Reply Last reply Reply Quote 0
      • Christian Ehrlicher
        Christian Ehrlicher Lifetime Qt Champion @odelaune last edited by

        @odelaune said in How should I organise translations of plugins?:

        for Qt Creator itself and all its plugins. I do not understand why this logic is used.

        Because all plugins are in the same git repo and not distributed indepentendly so no need to fiddle around with more than one translation file.

        Is there something specific with the plugin translations?

        No. You just need a schema to know which translation file belongs to which plugin.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        O 1 Reply Last reply Reply Quote 0
        • O
          odelaune @Christian Ehrlicher last edited by odelaune

          Ok, here is my progress. Here the CMakeLists.txt of my plugin

          set(TS_FILES
              i18n/MyPlugin_en.ts
              i18n/MyPlugin_fr.ts
          )
          
          # Adding translations
          qt_add_translations(MyPlugin
          TS_FILES ${TS_FILES}
          LUPDATE_OPTIONS -no-obsolete
          OUTPUT QM_FILES)
          
          install(FILES ${qm_files} DESTINATION ${CMAKE_INSTALL_BINDIR})
          

          Initially the MyPlugin_*.ts files are empty, so I need to go to the i18n folder and to run lupdate there. Then I translate strings.

          Finally, I compile. There is no error but the strings of MyPlugin are not translated.

          Any idea about what is missing?

          O 1 Reply Last reply Reply Quote 0
          • O
            odelaune @odelaune last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • First post
              Last post