QLocale::system()
-
Hello,
I am using following piese of code to read the system locale language and country
QStringList list = QLocale::system().name.split("_");foreach(QString language, list)
cout << language << endl;If I set the system language, Norwegian or Serbian, I get the locale as en_US only.
For all other languages, it works well, I get correct output. For example, for German I get de_DE.What might be the reason for this?
-
@Gayatri-Kulkarni said in QLocale::system():
QStringList list = QLocale::system().name.split("_");
foreach(QString language, list)
cout << language << endl;There is no need to do that. You can get the country from
QLocale
by using this:
https://doc.qt.io/qt-5/qlocale.html#countryToString@Gayatri-Kulkarni said in QLocale::system():
If I set the system language, Norwegian or Serbian, I get the locale as en_US only.
Check how Norwegian is detected in your app
If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).
(https://doc.qt.io/qt-5/qlocale.html#details)This is what probably happens
-
@Pl45m4 said in QLocale::system():
Check how Norwegian is detected in your app
Sorry, I do not understand:
Check how Norwegian is detected in your appCould you please elaborate?
-
@dheerendra , could you please provide your feedback on this issue?