gri
13th June 2007, 14:20
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
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;
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 :( :mad:
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
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;
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 :( :mad: