This is a discussion on Re: locale settings by language - KDE ; On Tuesday 26 July 2005 15:00, Tomasz Grobelny wrote: > Dnia Tuesday 26 of July 2005 02:32, David Faure napisa=B3: > > On Tuesday 26 July 2005 01:31, Tomasz Grobelny wrote: > > > Is it possible to get locale ...
On Tuesday 26 July 2005 15:00, Tomasz Grobelny wrote:
> Dnia Tuesday 26 of July 2005 02:32, David Faure napisa=B3:
> > On Tuesday 26 July 2005 01:31, Tomasz Grobelny wrote:
> > > Is it possible to get locale settings for a given language? For examp=
> > > want to format date in English while my current locale is Polish. If
> > > there is no appropriate function would such a code be safe (if it wor=
> > > at all): QString oldlang=3DKGlobal::locale()->language();
> > > KGlobal::locale()->setLanguage("en");
> > > QString dateInEnglish=3DKGlobal::locale()->formatDate(qdate);
> > > KGlobal::locale()->setLanguage(oldlang);
> > This isn't C, no need to set/reset a global state when you can instanci=
> > a class ;-)
> I felt it was not the best solution, that's why I asked. BTW, see =
Well.... someone went ahead without asking here first
Of course creating a KLocale instance might be expensive, so the solution
of creating one instead of switching the global one should probably only
be done when the other klocale can be kept somewhere and reused (like
> > KLocale englishLanguage("en");
> > QString dateInEnglish =3D englishLanguage.formatDate(qdate);
> > should work.
> But it doesn't. =
Sorry, the parameter isn't the language, but the instance name...
// Do this once when first needed
englishLanguage.setLanguage( "en_US" ); // or "C"
// Then do this to format a date in english
QString dateInEnglish =3D englishLanguage.formatDate(qdate);
[still untested though ]
> KLocale polishLanguage("pl_PL"); //"pl" doesn't work either
It's setLanguage("pl"). The string to use is the language as known in l10n/.
David Faure, email@example.com, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscrib=