QTranslator and qtbase_en.qm
-
Hi,
In my main.cpp I implemented the QTranslator like this:
QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath)); QLocale locale(QLocale::English, QLocale::UnitedStates); QTranslator qtBaseTranslator; qtBaseTranslator.load(locale, "qtbase", "_", translationsPath); qDebug() << "load2:"<< a.installTranslator(&qtBaseTranslator);
The Debug intormation is:
load1 true
load2: falseThe file "C:\Qt\5.13.0\mingw73_32\translations\qtbase_en.qm" exists, but the translator does not work.
Now I found out that the size of my "qtbase_en.qm"-file is only 1 KB; other qtbase_xy.qm-files have a size of 150KB to 200KB.
Where can I get a working "qtbase_en.qm"-file?
Thanks. -
@Mark58 said in QTranslator and qtbase_en.qm:
Where can I get a working "qtbase_en.qm"-file?
When you want an english - english translation you have to do it by yourself I would guess.
-
@Christian-Ehrlicher
Thanks, but that's not the problem. Maybe I tried to simplify my problem too much.The "qtbase_...qm" file should translate e.g. the buttonbox-Button.
I start my app in Spanish. Therefore I have a QTranslator in my main.cpp like this:QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath)); QLocale locale(QLocale::Spanish, QLocale::Spain); QTranslator qtBaseTranslator; qDebug() << "path" << qtBaseTranslator.load(locale, "qtbase", "_", translationsPath); qDebug() << "load:"<< a.installTranslator(&qtBaseTranslator);
This works fine and the buttonbox-Button is shown in spanish:
In my mainwindow.cpp I have three slots to change the language into german, french or english.
Generally, this works fine - e.g. for french:void MainWindow::on_pushButton_3_clicked() { //Francais QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath)); QLocale locale(QLocale::French, QLocale::France); QTranslator *qtBaseTranslator = new QTranslator(this); qDebug() << "path francais:" << qtBaseTranslator->load(locale, "qtbase", "_", translationsPath); qDebug() << "load francais:"<< qApp->installTranslator(qtBaseTranslator); }
This works fine as well. The Debug-output is:
path francais: true
load francais: trueThe buttonbox-Button - language changes to french:
My problem is, that the translation to English does not work:
void MainWindow::on_pushButton_4_clicked() { //English QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath)); QLocale locale(QLocale::English, QLocale::UnitedKingdom); QTranslator *qtBaseTranslator = new QTranslator(this); qDebug() << "trans" <<translationsPath; qDebug() << "path English:" << qtBaseTranslator->load(locale, "qtbase", "_", translationsPath); qDebug() << "translator empty?:" << qtBaseTranslator->isEmpty(); qDebug() << "load English:"<< qApp->installTranslator(qtBaseTranslator); }
The Debug - Output is:
trans "C:/Qt/5.13.0/mingw73_32/translations"
path English: true
translator empty?: true
load English: falseAs a consequence, the language changes back to Spanish, because this is the language in the main.cpp.
In the directory "C:/Qt/5.13.0/mingw73_32/translations" I have a qtbase_en.qm with a size of 1KB only.
Any help would be fine. Thanks.
-
If yoiu don't need a translator anymore, remove it.