QTranslate in win32/win64 applications do not work

Schneck Dennis CIS SDE Dennis.Schneck at heller.biz
Tue Jul 9 11:57:47 BST 2013


Hi,
i tryed to make the included "Hello World!" Example multilingual.
For Linux 32/64bit it works, but for win32/win64 it did not work.

Use: OpenSuSE 12.3 (64bit), Kdevelop 4.4.1, Linguist 4.8.4 mingw32/mingw64 4.8.4, qt 4.8.4, wine 1.5.23


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.cpp

#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"


test_w32.pro

SOURCES      = main.cpp test_w32.cpp
TRANSLATIONS = test_w32_de.ts



test_w32.pro

SOURCES      = main.cpp test_w32.cpp
TRANSLATIONS = test_w32_de.ts
developer at linux-jlfx:~/projects/test_w32> cat test_w32_de.ts
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="de_DE">
<context>
    <name>test_32</name>
    <message>
        <location filename="test_w32.cpp" line="12"/>
        <source>Hello World!</source>
        <translation>Hallo Welt!</translation>
    </message>
    <message>
        <location filename="test_w32.cpp" line="15"/>
        <source>Quit</source>
        <translation>Beenden</translation>
    </message>
    <message>
        <location filename="test_w32.cpp" line="17"/>
        <source>File</source>
        <translation>Datei</translation>
    </message>
</context>
</TS>




What did I wrong ?


Thanks



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop/attachments/20130709/eb53fbcc/attachment.html>


More information about the KDevelop mailing list