Is there a way to get the current default locale?
-
I see there is a Locale::setDefault but I am missing the Locale:default() method?
What I currently do, to have the default locale available for Translation loading in my projects components, I create a dynamic "locale" property on the QCoreApplication object instance. -
did you read the doc-description of the method?!
[quote]
Sets the global default locale to locale. These values are used when a QLocale object is constructed with no arguments. If this function is not called, the system's locale is used.
[/quote] -
@
std::cout << QLocale::system().name().toStdString() << std::endl;
std::cout << QLocale().name().toStdString() << std::endl;
@ -
[quote author="raven-worx" date="1375862253"]did you read the doc-description of the method?!
[quote]
Sets the global default locale to locale. These values are used when a QLocale object is constructed with no arguments. If this function is not called, the system's locale is used.
[/quote][/quote]Of course, I missed that in the docs. Works great!
-
If you want to translate your program, check that out:
@QString locale = QLocale::system().name().section('', 0, 0);
QTranslator translator;
translator.load(QString("qt") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&translator);@