Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.6
- import QtQuick.Controls 1.5
- ApplicationWindow {
- id: applicationWindow
- visible: true
- width: 640
- height: 480
- Label {
- id: helloLabel
- height: 50
- anchors {
- top: parent.top
- left: parent.left
- right: parent.horizontalCenter
- margins: 10
- }
- }
- ComboBox {
- id: comboBox
- anchors {
- top: parent.top
- left: parent.horizontalCenter
- right: parent.right
- margins: 10
- }
- model: ["ru_RU", "en_US"]
- // If you change the text, initialize the translation unit via C++ Layer
- onCurrentTextChanged: {
- qmlTranslator.setTranslation(comboBox.currentText)
- }
- }
- Label {
- id: labelText
- wrapMode: Text.Wrap
- anchors {
- top: helloLabel.bottom
- left: parent.left
- right: parent.right
- margins: 10
- }
- }
- // Connect to an interpreter object
- Connections {
- target: qmlTranslator // was registered in main.cpp
- onLanguageChanged: {
- // upon receipt of the signal to change the language
- retranslateUi() // initialize interface translation
- }
- }
- // interface translation function
- function retranslateUi() {
- applicationWindow.title = qsTr("Hello World")
- helloLabel.text = qsTr("Hello World")
- labelText.text = qsTr(
- "The QTranslator class provides internationalization"
- + "support for text output.An object of this class contains "
- + "a set of translations from a source language to a target language. "
- + "QTranslator provides functions to look up translations in a translation file. "
- + "Translation files are created using Qt Linguist.")
- }
- // Start translating the application window when the application was created
- Component.onCompleted: {
- retranslateUi()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement