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.tsis created in your project structure. - Next, you add a
QLabelto the.uifile and addWelcometext. - Next, run
lupdate. You can runlupdatefrom the command line as well as from the Qt Creator interface, as shown in Figure 11.3:Figure 11.3 – Qt Linguist options in Qt Creator
- When you run
lupdate, you will see the following...