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