Solved How to make use of internationalization?
-
This is main.cpp file
#include <QGuiApplication> #include <QtGui> #include <QQuickView> #include <QTranslator> #include <QQmlContext> #include <QQmlProperty> #include <QCoreApplication> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQuickView view; QTranslator *translator1=new QTranslator(); translator1->load("xyz.ts"); QCoreApplication::installTranslator(translator1); view.setSource(QUrl::fromLocalFile("C:/Users/nisha.r/Desktop/untitled/asa.qml")); view.show(); return app.exec(); }
This is asa.qml file
import QtQuick 2.7 import QtQuick.Window 2.2 Rectangle{ Text { anchors.fill: parent text:qsTr("hello") } }
ts file that is loaded is not reflected when executed.
-
-
@Julien-B thank you,
i have tried with that , but still the same. -
Hope you have included all your strings in cml using qstr. Run lupdate on the pro file. This generates the *.ts files. Now use Linquist tool & open the .ts file. Do all the conversions. Generate the *.qm(qm not QML). Now load the .qm file and install it as you done. This works.
-
@Nisha_R perhaps my blog post will give you some ideas.
-
@dheerendra thank you it worked, i had missed giving a path for qm file. in load function.
@ekkescorner i shall look into it, thank you.