
Qt → Qt/C++ Tutorial 092. Creating translations for external text sources
Qt 6, Qt, Qt 5, QtLinguist, translation
Today we will discuss a rather interesting option for adding translation to a Qt/C++ application. Namely, adding translations for texts from external sources when you display texts from databases, an external API, or just some other files.
Such a situation can arise in the following case, for example, analysts in your project form sets of data and texts in some external database or text files, but there is no possibility of multilingualism for some reason. And therefore, you do not have the option to select the language as an additional parameter when requesting this data. Or, for example, the final data is downloaded from an external resource and stored in a SQLite database, of course, without additional translations. But at the same time, you are developing a multilingual application and you need to somehow generate translation files for these texts, so that the translation team can translate them, and you can connect them in the application.
But in Qt it is possible to solve this problem as well. In such situations, you can also generate source code files in the same way, for example, generate them when importing data during application development, and then generate translation files with the extension *.ts , which are used in QtLinguist to translate the application to Qt, and then generate binary *.qm translation files that will be included in the application.
Let's see how it works and what needs to be done for this.

QML → QML - Lesson 025. Dynamic translation of multilanguage application on QML
QTranslator, перевод, Qt, QML, translation
Once we have learn how to make the translation of the application interface at Qt/C++ , it is time to research possibilities of dynamic translation application interface which is written in QML.
In developing the QML to have a couple of moments that need to be taken into account, as opposed to the standard application on QWidgets, namely:
- Requires additional configuration .pro file;
- Process of the loading of translation for your language is carried in C ++ layer;
- Reinitialize the translation interface implemented in QML layer using qsTr() function;
- After loading the translation, you need to send a signal from the C ++ layer in QML layer to re-translate the application interface.
Project Structure
Create a project, which will include the following files:
- QmlLanguage.pro - profile of project;
- deployment.pri - configuration file of deployment, created by default;
- main.cpp - source file of file with main function;
- qmltranslator.h - header file of class for translation loading;
- qmltranslator.cpp - sourcefile of class for translation loading;
- main.qml - main file of QML layer.
Fornex
Let me recommend you a great European Fornex hosting.
Fornex has proven itself to be a stable host over the years.
For Django projects I recommend VPS hosting
Following the link you will receive a 5% discount on shared hosting services, dedicated servers, VPS and VPN
View HostingShare on social networks
Donate
The EVILEG project has switched to a non-commercial basis and will develop solely on the enthusiasm of the site creator, the enthusiasm of users, donations and the hosting referral system
Thank you for your support
Available ways to support the project
PayPal
PatreonYandex.MoneyMore