vermarajeev
16th November 2006, 08:54
Hi guys,
I'm working with a sample program, where I need to make my application translated to other language other than English. I went through Qt linguist manual and followed the steps for translation.
Can you guys tell me why m not able to convert the english text to french
Here is my sample program
--------------------------------------------------------------------------------------------------
//myfile.h
class ArrowPad : public QWidget
{
Q_OBJECT
public:
ArrowPad(QWidget *parent=0, const char *name="ArrowPad" );
~ArrowPad(){}
private:
QPushButton* up;
QPushButton* left;
QPushButton* right;
QPushButton* down;
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent=0, const char *name="MainWindow" );
~MainWindow(){}
private:
QPopupMenu * file;
};
------------------------------------------------------------------------------------------------------
//myfile.cpp
ArrowPad::ArrowPad(QWidget *parent, const char *name)
: QWidget(parent, name)
{
up = new QPushButton(tr("&UP"), this) ;
up->setGeometry(200, 100, 40, 40);
left = new QPushButton(tr("&LEFT"), this) ;
left->setGeometry(150, 140, 40, 40);
right = new QPushButton(tr("&RIGHT"), this) ;
right->setGeometry(250, 140, 40, 40);
down = new QPushButton(tr("&DOWN"), this) ;
down->setGeometry(200, 180, 40, 40);
}
MainWindow::MainWindow(QWidget *parent, const char *name)
:QMainWindow(parent, name)
{
file = new QPopupMenu(this);
menuBar()->insertItem( tr("&File"), file);
file->insertItem( tr("E&xit"), qApp, SLOT(quit()),
tr("Ctrl+Q", "Quit") );
ArrowPad *ap = new ArrowPad( this, "arrow pad" );
setCentralWidget(ap);
resize(500, 500);
}
------------------------------------------------------------------------------------------------------
//main.cpp
#include <qapplication.h>
#include <qpushbutton.h>
#include <qtranslator.h>
#include <qtextcodec.h>
#include "test.h"
int main( int argc, char **argv )
{
QApplication app( argc, argv );
MainWindow mw;
QTranslator translator( 0 );
translator.load( "tt2_fr", "." );
app.installTranslator( &translator );
app.setMainWidget( &mw );
mw.show();
return app.exec();
}
I have also created *.ts and *.qm files using lupdate and lrelease but still the program shows me english text. I have taken this sample from Qt linguist manual, section->Programmers
Any comment will be highly appreciated
Thanx
I'm working with a sample program, where I need to make my application translated to other language other than English. I went through Qt linguist manual and followed the steps for translation.
Can you guys tell me why m not able to convert the english text to french
Here is my sample program
--------------------------------------------------------------------------------------------------
//myfile.h
class ArrowPad : public QWidget
{
Q_OBJECT
public:
ArrowPad(QWidget *parent=0, const char *name="ArrowPad" );
~ArrowPad(){}
private:
QPushButton* up;
QPushButton* left;
QPushButton* right;
QPushButton* down;
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent=0, const char *name="MainWindow" );
~MainWindow(){}
private:
QPopupMenu * file;
};
------------------------------------------------------------------------------------------------------
//myfile.cpp
ArrowPad::ArrowPad(QWidget *parent, const char *name)
: QWidget(parent, name)
{
up = new QPushButton(tr("&UP"), this) ;
up->setGeometry(200, 100, 40, 40);
left = new QPushButton(tr("&LEFT"), this) ;
left->setGeometry(150, 140, 40, 40);
right = new QPushButton(tr("&RIGHT"), this) ;
right->setGeometry(250, 140, 40, 40);
down = new QPushButton(tr("&DOWN"), this) ;
down->setGeometry(200, 180, 40, 40);
}
MainWindow::MainWindow(QWidget *parent, const char *name)
:QMainWindow(parent, name)
{
file = new QPopupMenu(this);
menuBar()->insertItem( tr("&File"), file);
file->insertItem( tr("E&xit"), qApp, SLOT(quit()),
tr("Ctrl+Q", "Quit") );
ArrowPad *ap = new ArrowPad( this, "arrow pad" );
setCentralWidget(ap);
resize(500, 500);
}
------------------------------------------------------------------------------------------------------
//main.cpp
#include <qapplication.h>
#include <qpushbutton.h>
#include <qtranslator.h>
#include <qtextcodec.h>
#include "test.h"
int main( int argc, char **argv )
{
QApplication app( argc, argv );
MainWindow mw;
QTranslator translator( 0 );
translator.load( "tt2_fr", "." );
app.installTranslator( &translator );
app.setMainWidget( &mw );
mw.show();
return app.exec();
}
I have also created *.ts and *.qm files using lupdate and lrelease but still the program shows me english text. I have taken this sample from Qt linguist manual, section->Programmers
Any comment will be highly appreciated
Thanx