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. How should I organise translations of plugins?
QtWS25 Last Chance

How should I organise translations of plugins?

Scheduled Pinned Locked Moved Unsolved General and Desktop
plugintranslation
4 Posts 2 Posters 451 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.
  • O Offline
    O Offline
    odelaune
    wrote on 6 Jul 2023, 14:37 last edited by
    #1

    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?

    C 1 Reply Last reply 6 Jul 2023, 14:49
    0
    • O odelaune
      6 Jul 2023, 14:37

      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?

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 6 Jul 2023, 14:49 last edited by
      #2

      @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 7 Jul 2023, 07:08
      0
      • C Christian Ehrlicher
        6 Jul 2023, 14:49

        @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.

        O Offline
        O Offline
        odelaune
        wrote on 7 Jul 2023, 07:08 last edited by odelaune 7 Dec 2023, 12:25
        #3

        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 12 Jul 2023, 12:24
        0
        • O odelaune
          7 Jul 2023, 07:08

          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 Offline
          O Offline
          odelaune
          wrote on 12 Jul 2023, 12:24 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0

          1/4

          6 Jul 2023, 14:37

          • Login

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