Hello there,
I'm confusing myself with QLocale, maybe someone of you can help me 
I simply want to get the language code for a language. "languageToCode()" would be exactly what I want to have but this is only an internal function by qlocale.cpp.
So I tried by using this:
QLocale locale
(QLocale::German,
QLocale::AnyCountry);
// Docs say AnyCountry takes the most appropriate country ... I DONT WANT THIS QString code
= locale.
name();
// this returns "de_DE" ... nice
QLocale locale(QLocale::German, QLocale::AnyCountry); // Docs say AnyCountry takes the most appropriate country ... I DONT WANT THIS
QString code = locale.name(); // this returns "de_DE" ... nice
To copy to clipboard, switch view to plain text mode
My problem is, I only wanted the "de" in front and I don't like to split the string cause this is unpretty!
Then I looked at the QLocale::name() which has the following code fragment:
Country c = country();
if (c == AnyCountry)
return result;
Country c = country();
if (c == AnyCountry)
return result;
To copy to clipboard, switch view to plain text mode
Wow. If the constructor wouldnt change AnyCountry to German I would get what I want!
There is no way to set the country outside of the constructor of QLocale ... so what now?!
Thanks, gri
PS: So much time about a simple thing
Bookmarks