Results 1 to 2 of 2

Thread: QLocale::system().name() returns "C" instead of "de"

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QLocale::system().name() returns "C" instead of "de"

    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?

    Qt Code:
    1. #include <QApplication>
    2. #include <QDebug>
    3. #include <QLocale>
    4. #include <QTranslator>
    5. #include "pollmonitor.h"
    6. #include "mainwindow.h"
    7.  
    8. #include <iostream> // DEBUG
    9.  
    10. int main(int argc, char* argv[])
    11. {
    12. QApplication app(argc, argv);
    13. app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
    14.  
    15. // Settings
    16. QCoreApplication::setOrganizationName("MLHB");
    17. QCoreApplication::setOrganizationDomain("mlhb.de");
    18. QCoreApplication::setApplicationName("Hygiene-Befund");
    19.  
    20. // Translations
    21. QString locale = QLocale::system().name();
    22. qDebug() << locale; // DEBUG
    23.  
    24. QTranslator appTranslator;
    25. QTranslator qtTranslator;
    26. QString appTranslation = app.applicationDirPath()
    27. + "/../translations/" + QString("dirmon_" + locale + ".qm");
    28. QString qtTranslation = app.applicationDirPath()
    29. + "/../translations/" + QString("qt_" + locale + ".qm");
    30.  
    31. // Load App Translation file
    32. bool b;
    33. b = appTranslator.load(appTranslation);
    34. if (!b)
    35. qDebug() << app.tr("couldn't load translation file %1").arg(appTranslation).toLatin1();
    36.  
    37. // Load Qt Translation file
    38. b = qtTranslator.load(qtTranslation);
    39. if (!b)
    40. qDebug() << app.tr("couldn't load translation file %1").arg(qtTranslation);
    41.  
    42. app.installTranslator(&appTranslator);
    43. app.installTranslator(&qtTranslator);
    44.  
    45. // Main Window
    46. MainWindow mw;
    47. mw.show();
    48. return app.exec();
    49. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2007
    Posts
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLocale::system().name() returns "C" instead of "de"

    I have found the same error in other project. But still, i haven't found the reason. Maybe someone can enlighten us

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.