Sample program hellotr.pro cannot build and run. Why? (Solved)
-
I could not build the sample program(hellotr.pro) in Qt5.3.1.
Please kindly advice. Very difficult for a newie to see the error.
The examples is in /home/common/Qt5.3.1/Examples@
===hellotr.pro==========================================
SOURCES = main.cpp
TRANSLATIONS = hellotr_la.tstarget.path = /home/common/Qt5.3.1/Examples/Qt-5.3/linguist/hellotr
INSTALLS += target sourcesQT += widgets
#simulator: warning(This example might not fully work on Simulator platform)
@@
===main.cpp================================================
#include <QApplication>
#include <QPushButton>
#include <QTranslator>int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTranslator translator;translator.load("hellotr_la"); app.installTranslator(&translator); QPushButton hello(QPushButton::tr("Hello world!")); hello.resize(100, 30); hello.show(); return app.exec();
}
@[edit: added missing coding tags @ SGaist]
-
under linguist examples, i cannot set the hello world to thai language
-
i am following the link below
http://qt.developpez.com/doc/4.7/linguist-hellotr/Do i have to do the translation myself, i thought it is done automatically?
1.in linguist/hellotr, initially there is only two file
hellotr.pro & main.cpp2.after running "lupdate -verbose hellotr.pro"
hellotr_la.ts file is created.3.after running "linguist hellotr_la.ts"
hellotr_la.qm file is created.=xml format =================================
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="th_TH" sourcelanguage="en_SG">
<context>
<name>QPushButton</name>
<message>
<location filename="main.cpp" line="63"/>
<source>Hello world!</source>
<translatorcomment>Orbis, te saluto !</translatorcomment>
<translation>Orbis, te Saluto!</translation>
</message>
</context>
</TS> -
i build and run successfully, but it is always same language "hello world"
-
Hi,
@translator.load(“hellotr_la”); << Used like that it searches for the file in the application path@
Do you have the translation file in the same folder as your application ?
-
I don't have the translation file. Where to get it? do you have the link?
i am following the link below
http://qt.developpez.com/doc/4.7/linguist-hellotr/did i miss anything?
-
there are 13 label that i would like to toggle between thai language and english. I will be using QxmlStreamReader to read both language.
-
There's no need to add QxmlStreamReader for this.
You have generated the hellotr_la.qm file. Probably in your source folder. So you have two solutions here:
Copy that file in the build directory, in the same folder as your application
Give the full path to that file to QTranslator
-
Can guide on how to toggle between thai and english language using a timer on Mainwindow? Many thanks
-
I managed to toggle between two language. Now my concern is how to plug English and thai from a txt file.
In these txt file, there is a translation list. (English & Thai)QString line;
do {
line =stream.readLine();
qDebug()<<line;
}while(!line.isNull()); -
https://www.youtube.com/watch?v=V9Gep6-r8ns
Attach is the youtube on how translation can be done in Qt