Translations of QMessageBox not work in Qt5.3
Asked Answered
H

3

3

I'm a fan of Qt and update it frequently, Qt5.1->5.2->5.3.

However, the tranalations of Standard buttons like "Ok" "Cancel" "Save" do not work anymore in Qt5.3. They are not translated, but just plain English.

The Code for translations does NOT change through each version of Qt. like:

TRANSLATIONS = qt_fr.ts
QTranslator trans
trans.load("qt_fr");
a.installTranslator(&trans);

any idea?

[Update] AFAIN, it might be a bug. Go back to Qt5.1 is a slution if U dont have to use some improvements in new Qts.

Highcolored answered 15/9, 2014 at 14:13 Comment(4)
If your program works right under Qt 5.2 and the exact same program does not work right Qt 5.3, it's probably a Qt bug and your best option is to report it to Digia. Be sure to include a small compileable example program that demonstrates the problem.Tippets
Hmm, that's odd, I have the same problem, what OS do you use?Leicester
@JeremyFriesner thanks, ur right. i way back to Qt5.1.Highcolored
@JulienLopez win7/8/xp, it's a bug(or some reason i havent figured out). suggest u to way back to Qt5.1 if possible.Highcolored
W
4

Starting from Qt5.3 the qt_*.qm is divided into multiple files (qt*_*.qm) and now you have to copy qtbase_*.qm to translation directory and use together.

QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
QLocale locale = QLocale::system();

QTranslator qtTranslator;
if (qtTranslator.load(locale, "qt", "_", translationsPath))
    a.installTranslator(&qtTranslator);

QTranslator qtBaseTranslator;
if (qtBaseTranslator.load(locale, "qtbase", "_", translationsPath))
    a.installTranslator(&qtBaseTranslator);
Weltpolitik answered 12/1, 2015 at 17:24 Comment(0)
A
2

I had the same problem and got it to work with an updated translation file. I am not sure if this is the intended behaviour, but my qt_de.qm has a filesize of only 1kB. There is however a file called qtbase_de.qm now (154kB) which seems to do the trick.

Azure answered 27/11, 2014 at 7:8 Comment(0)
A
2

This is source of qt_ru:

   <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE TS>
    <TS version="2.0" language="ru">
    <dependencies>
        <dependency catalog="qtbase_ru"/>
        <dependency catalog="qtscript_ru"/>
        <dependency catalog="qtquick1_ru"/>
        <dependency catalog="qtmultimedia_ru"/>
        <dependency catalog="qtxmlpatterns_ru"/>
    </dependencies>
    </TS>

Therefore, it is necessary to deploy application with all these translation files. If at least one file is missing, the translation qt_ru will not load.

Arkansas answered 19/9, 2015 at 7:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.