Tuesday, July 28, 2009

Re: Display months in datetime fields in german

I don't want to overemphasize this but you cannot safely use setlocale
(). With some setups it might be OK to rely on it but in general I
wouldn't recommend using it. As you can read in the warning message at
http://php.net/setlocale the function is maintained for the whole
process not per thread. Which means that if you're running a
multithreaded server and you're setting the locale at the very
beginning and localize at the end when processing the response of a
request sth like this might happen:

setlocale(LC_ALL, 'en_US') strftime('%A')
| |
A >---------------------------------------<

setlocale(LC_ALL, 'fr_FR') strftime('%A')
| |
B >---------------------------------------<

Assumed today is monday, the english speaking user gets 'lundi'
instead of the expected 'monday'. Currently for something like
localizing the month names, doing message translation is the better
choice even though I see the limitations of it.

- David

On 28 Jul., 23:52, ohcibi <i...@dwgadf.de> wrote:
> you should _never_ do any stringsubstitutions for localizing month
> names... _always_ use setlocale and maybe an extra helper for more
> comfort. stringsubstitutions are an unnecessary extra task and may not
> even work proper (e.g. if the php setup has another default language)
>
> On Jul 28, 11:03 am, Piotr Kilczuk <kilc...@gmail.com> wrote:
>
> > Hello,
>
> > > with "ger" it didn't work but when I changed the folder name to
> > > "deu" (and also the value in Config.language of course) it worked like
> > > a charme.
> > > For some reason it seems that it has(!) to be named "deu"....
> > > anyway, thanks a lot!
>
> > That's good. German has two ISO-639-2 codes, I thought you could use
> > both, thanks for sharing your knowledge :)
>
> > Regards,
> > Piotr
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: