Internationalization with Qt Quick
In the previous section, we discussed internationalization in Qt Widgets. In this section, we will discuss different aspects of internationalizing your Qt Quick application. The underlying localization scheme in Qt Quick applications is similar to Qt Widgets applications. The same set of tools described in the Qt Linguist Manual are also used in Qt Quick. You can translate an application that uses both C++ and QML.
In a Qt project file, the SOURCES
variable is used for C++ source files. If you list QML or JavaScript files under this variable, the compiler will attempt to use the files considering them as C++ files. As a workaround, you can use a lupdate_only {...}
conditional declaration to make the QML files visible to the lupdate
tool but invisible to the C++ compiler.
Consider the following example. The application's .pro
file snippet lists two QML files:
lupdate_only { SOURCES = main.qml \ Â Â Â Â Â Â Â ...