internationalisation problem

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
mink
Active Member
Posts: 30
Joined: Mon Jan 19, 2015 7:20 pm

internationalisation problem

Post by mink » Tue Mar 24, 2015 4:09 pm

Hello again,

and again a problem .... this time with ui translations of c++ plugin.

I did:
- use english as ui language in sources and ui files
- generate .ui files with Qt designer
- surrounded strings in my c++-sources with tr() (or QObject::tr() ) (only those I want to be translated
- added the following code to my plugins postInit()

Code: Select all

    QString locale = QLocale::system().name();
    QTranslator translator;
    translator.load(QString("ts/DACAD_") + locale);
    qApp->installTranslator(&translator);
lupdate generated a ts file containing all strings I expected (target language german).
I translated all strings using linguist.
after this, lrelease generated a .qm file.
DACD_de.ts and DACD_de.qm were both copied to "qcad base directory"/ts.
I checked that after start of qcad translator.load() returns true.

Running the application shows that strings I set into the applications menu are translated to german (good).
However, the Dialogs from the .ui files show up in english (so untranslated, bad).

Any idea what I am missing???

Regards,

Ulrich

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: internationalisation problem

Post by andrew » Tue Mar 24, 2015 4:34 pm

Try allocating the translator dynamically:
QString locale = QLocale::system().name();
QTranslator* translator = new QTranslator(qApp);
translator->load(QString("ts/DACAD_") + locale);
QCoreApplication::installTranslator(translator);

mink
Active Member
Posts: 30
Joined: Mon Jan 19, 2015 7:20 pm

Re: internationalisation problem

Post by mink » Tue Mar 24, 2015 4:44 pm

Thanks, Andrew.

Good hint - it works!

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”