Hi, I am working on a german windows 2000 workstation and wanted to try out a little application that I have written for our company. I had created translation files and wanted to load them at startup but realised they were not loaded. After putting in debug print statements I found out that the locale returned is "C" -- the fallback default locale -- as opposed to "de" which should be the case since this is a german windows installation. Can anybody tell me what I am doing wrong? May it be a windows 2000 issue?
#include <QApplication>
#include <QDebug>
#include <QLocale>
#include <QTranslator>
#include "pollmonitor.h"
#include "mainwindow.h"
#include <iostream> // DEBUG
int main(int argc, char* argv[])
{
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
// Settings
// Translations
qDebug() << locale; // DEBUG
QString appTranslation
= app.
applicationDirPath() + "/../translations/" + QString("dirmon_" + locale
+ ".qm");
QString qtTranslation
= app.
applicationDirPath() + "/../translations/" + QString("qt_" + locale
+ ".qm");
// Load App Translation file
bool b;
b = appTranslator.load(appTranslation);
if (!b)
qDebug() << app.tr("couldn't load translation file %1").arg(appTranslation).toLatin1();
// Load Qt Translation file
b = qtTranslator.load(qtTranslation);
if (!b)
qDebug() << app.tr("couldn't load translation file %1").arg(qtTranslation);
app.installTranslator(&appTranslator);
app.installTranslator(&qtTranslator);
// Main Window
MainWindow mw;
mw.show();
return app.exec();
}
#include <QApplication>
#include <QDebug>
#include <QLocale>
#include <QTranslator>
#include "pollmonitor.h"
#include "mainwindow.h"
#include <iostream> // DEBUG
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
// Settings
QCoreApplication::setOrganizationName("MLHB");
QCoreApplication::setOrganizationDomain("mlhb.de");
QCoreApplication::setApplicationName("Hygiene-Befund");
// Translations
QString locale = QLocale::system().name();
qDebug() << locale; // DEBUG
QTranslator appTranslator;
QTranslator qtTranslator;
QString appTranslation = app.applicationDirPath()
+ "/../translations/" + QString("dirmon_" + locale + ".qm");
QString qtTranslation = app.applicationDirPath()
+ "/../translations/" + QString("qt_" + locale + ".qm");
// Load App Translation file
bool b;
b = appTranslator.load(appTranslation);
if (!b)
qDebug() << app.tr("couldn't load translation file %1").arg(appTranslation).toLatin1();
// Load Qt Translation file
b = qtTranslator.load(qtTranslation);
if (!b)
qDebug() << app.tr("couldn't load translation file %1").arg(qtTranslation);
app.installTranslator(&appTranslator);
app.installTranslator(&qtTranslator);
// Main Window
MainWindow mw;
mw.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks