PDA

View Full Version : Translation problem



Raadush
9th May 2012, 10:43
Hi, I have this problem. I need to add translations to my application, but I never worked with it and so I really dont know what im doing wrong. Can some kind soul help me? :) I have main.cpp:

#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QTranslator qtTranslator;
qtTranslator.load("project_eng");
a.installTranslator(&qtTranslator);

MainWindow w;
w.show();

return a.exec();
}





mainwindow.cpp:
<code>
#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QLabel *label = new QLabel(this);
label->setText(tr("Hello world"));
this->setCentralWidget(label);
}

MainWindow::~MainWindow()
{

}




and project.pro:
QT += core gui

TARGET = project
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

TRANSLATIONS += project_eng.ts


I have created ts file with lupdate project.pro, translated text with linguist, called lrelease project.pro which said "Generated 1 translation(s) (1 finished and 0 unfinished)" but when I run my app i still get "Hello world" and not my translation. What Im doing wrong?

Added after 32 minutes:

Ok, problem solved, I was doing shadow build into different folder which didnt contain translation file.