I tried to change locale using QLocale and setDefault function but it seems that it doesn\'t work. Here is example of changing locale using C localization library and QLocal
QLocale::setDefault()
does not change the system locale. It changes what QLocale
object created with default constructor is.
Supposedly, system locale can only be changed via system control panel/preferences by the user. If you want to format something that is not in the system locale, you need to specifically do that with a locale object.
This code:
QLocale curLocale(QLocale("pl_PL"));
QLocale::setDefault(curLocale);
QDate date = QDate::currentDate();
QString dateString = QLocale().toString(date);
qDebug() << dateString;
qDebug() << QLocale().name();
Prints this:
"piątek, 9 listopada 2012"
"pl_PL"