[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: locale settings by language
From:       Tomasz Grobelny <grotk () poczta ! onet ! pl>
Date:       2005-07-26 13:00:30
Message-ID: 200507261500.30592.grotk () poczta ! onet ! pl
[Download RAW message or body]

Dnia Tuesday 26 of July 2005 02:32, David Faure napisał:
> On Tuesday 26 July 2005 01:31, Tomasz Grobelny wrote:
> > Is it possible to get locale settings for a given language? For example I
> > 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 works
> > at all): QString oldlang=KGlobal::locale()->language();
> > KGlobal::locale()->setLanguage("en");
> > QString dateInEnglish=KGlobal::locale()->formatDate(qdate);
> > KGlobal::locale()->setLanguage(oldlang);
>
> This isn't C, no need to set/reset a global state when you can instanciate
> a class ;-)
>
I felt it was not the best solution, that's why I asked. BTW, see 
kdepim/libkmime/kmime_util.cpp:715

> KLocale englishLanguage("en");
> QString dateInEnglish = englishLanguage.formatDate(qdate);
>
> should work.
But it doesn't. Neither does my (previous) code. I have withhen sth like this:
  KLocale polishLanguage("pl_PL"); //"pl" doesn't work either
  ret = polishLanguage.formatDateTime(qdate, shortFormat, includeSecs);
  kdDebug()<<ret<<" "<<polishLanguage.language()<<endl;
and I got this:
  kmail: pl Monday 25 of July 2005 10:38 en_US

Tomek
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic