Wednesday, July 29, 2009

Re: Display months in datetime fields in german

The way how CakePHP handles the message translation is not affected by
setlocale and thus you would get 'monday' in that case. Cake uses a
PHP only solution for translating messages working around the
limitations of gettext in PHP.

- David

On 29 Jul., 04:29, ohcibi <i...@dwgadf.de> wrote:
> okay, i didnt knew that..
> but anyway, if another script uses setlocale you're running into the
> same problem (the stringsubstitution expects monday, but gets lundi
> und does nothing, so the user gets lundi at the end). so lets hope php
> will do things better in the future 8-)
>
> On Jul 29, 2:03 am, David Persson <davidpers...@gmx.de> wrote:
>
> > 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 athttp://php.net/setlocalethefunction 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: