Fwd: Using multiple klocales uses stale translations
Stephen Kelly
steveire at gmail.com
Mon Nov 8 23:29:13 GMT 2010
Chusslove Illich wrote:
>> [: Stephen Kelly :]
>> Clearly someone decided that should be commented out. Should what I am
>> trying work already, or does that need to be uncommented?
>
> It was I who both added and later commented out that code. As per the
> note, I commented it out because I didn't think of the use case, even
> though KLocalizedString::toString methods advertise the capability :) So
> it should be uncommented, but let me first check what it will do to
> performance.
The use cases I'm trying to satisfy are where you need to create content in
multiple locales, such as a mail-merge where the targets are in different
locales and the content should be localized.
>
>> KLocale de("kwrite", "de");
>> [...]
>> kDebug() << de.formatDate(now, KLocale::ShortDate);
>> kDebug() << fr.formatDate(now, KLocale::ShortDate);
>>
>> I always get the date in the system locale instead of de or fr. Shouldn't
>> that work?
>
> The second argument to KLocale constructor is the language, whereas the
> date is determined by country, which is the third parameter. If the
> country parameter is left out, it is fetched from "the system" (whatever
> that means), hence what you are seeing.
>
Thanks for that.
It took me a while to figure out that the country must be in lower case.
KLocale de_DE("kwrite", "de", "DE"); // does not work
KLocale de_DE("kwrite", "de_DE"); // does not work
KLocale de_DE("kwrite", "de_DE.UTF-8"); // does not work
KLocale de_DE("kwrite", "de", "de"); // works!
All the best,
Steve.
More information about the kde-core-devel
mailing list