Internationalization with Qt Widgets
In the previous sections, we discussed how to create translation files and how to use QTranslator
to load a translation file. Let's create a simple example using Qt Widgets and implement our learning.
Follow the subsequent steps to create the sample application:
- Create a Qt Widgets-based application using Qt Creator's new project creation wizard and follow through the screens as discussed in earlier chapters.
- On the Translation File screen, choose German (Germany) as the language option, or any preferred language.
- Finish the project creation. You will see that
Simplei18nDemo_de_DE.ts
is created in your project structure. - Next, you add a
QLabel
to the.ui
file and addWelcome
text. - Next, run
lupdate
. You can runlupdate
from the command line as well as from the Qt Creator interface, as shown in Figure 11.3: - When you run
lupdate
, you will see the following...