Translating Qt Widgets applications
First, let's create a new Qt Widget project, whose name is Internationalization
. Then, edit mainwindow.ui
in the Design mode.
As usual, remove the status bar, menu bar, and tool bar.
Add Label into
centralWidget
and change its object name tononTransLabel
. Then, change its text toThis is a non-translatable label
and unchecktranslatable
undertext
in Property Editor.Drag a Push Button just beneath
nonTransLabel
withtransButton
as its object name. Change its text toThis is a translatable button
.Change Lay out to Lay Out Vertically in MainWindow.
Resize the frame to a comfortable size.
Go back to editing the Internationalization.pro
project file in the Edit mode. Add a line indicating the translation source file, which is shown as follows:
TRANSLATIONS = Internationalization_de.ts
The _de
suffix is a locale code, indicating that this is a German translation source file. The locale codes are defined by Internet Engineering Task Force in the BCP 47 document series...