0

I have a weird problem translating my qt application (qt 4.7.4 on Windows). What happens is the following:

1.- I execute lupdate and generate a .ts file.

2.- I edit the generated .ts file with qt linguist.

3.- I execute lrelease with the previous .ts file.

4.- From Netbeans, I clean and build the project and then run it.

When my application runs, most widgets (labels, pushbuttons, titles, menu actions, menus) are translated according to the translation file that i generated before. The problem is that some elements are not being translated although i provided a translation for them in the translation file (Qt Linguist recognized them).

My question is: is there a reason why some texts are being translated while others are being ignored?

I have made sure that every text is inside a tr(). (As I said before, they all appear in Qt Linguist).

Thanks for all the help.

acerqueiro
  • 29
  • 5
  • And also you've made sure that each occurence of tr is called after install translator? – Kamil Klimek Aug 21 '12 at 22:56
  • Hi @KamilKlimek the translator is installed in the main function. After the call to the translator i call my mainWindow class and there is where all fails, the QMainWindow is not being translated :S the rest of the application is. I don't know what the problem is – acerqueiro Aug 23 '12 at 14:32
  • 2
    You must provide us minimal code example that reproduces your problem. – Kamil Klimek Aug 24 '12 at 07:02

1 Answers1

0

so it works for me only for Linux and not with mingw32/mingw64

main.cpp

#include <QtGui/QApplication>
#include "test_w32.h"
#include <QTranslator>
#include <QLocale>


int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    QString locale = QLocale::system().name();
    QTranslator translator;
    translator.load(QString("test_w32_") +locale);
    app.installTranslator(&translator);
    test_w32 foo;
    foo.show();
    return app.exec();
}

test_w32.h

#ifndef test_w32_H
#define test_w32_H

#include <QtGui/QMainWindow>

class test_w32 : public QMainWindow
{
Q_OBJECT
public:
    test_w32();
    virtual ~test_w32();
};

#endif // test_w32_H

test_w32.cpp

#include "test_w32.h"

#include <QtGui/QLabel>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QAction>


test_w32::test_w32()
{
    QLabel* l = new QLabel( this );
    l->setText(trUtf8( "Hello World!" ));
    setCentralWidget( l );
    QAction* a = new QAction(this);
    a->setText(trUtf8( "Quit" ));
    connect(a, SIGNAL(triggered()), SLOT(close()) );
    menuBar()->addMenu(trUtf8( "File" ))->addAction( a );
}

test_w32::~test_w32()
{}

#include "test_w32.moc"

Whats the problem ? Thanks