setlocale and news etc

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
pinthenet

setlocale and news etc

Post by pinthenet »

Could someone point me to an up-to-date summary of the steps required to get international dates out of News or other modules plse? I have found several references using search and I've tried nearly all combinations and still get english month names. I'm missing something somwhere.

I've temporarily got around the problem by using numeric only date formats but I really need month names (day names would also be useful sometimes)

Plse help
Thanks
John
pinthenet

Re: setlocale and news etc -story so far

Post by pinthenet »

Just to summarise, I've tried
  • setting locale="de_DE" in config.php
  • creating a tag {setlocale(LC_ALL, "de_DE") and inserting it in the content, before {cms_module module="news"....
  • adding support for an additional 'locale' parameter in the News module
But with a date format of %Y %b %d" I always get english codes.

Should I use $entry->postdate or $entry-formatpostdate in the News template?

I would be really, really grateful if soemone could clear this  up for me and perhaps even record it somewhere centrally so it's easy to find (when I forget again in 6 months) - I thought I'd solved this in Spring but  I've had a few months break form cmsms and now I'm on 0.11beta5

John
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: setlocale and news etc

Post by Ted »

postdate is still there so that it doesn't break old sites.  However, formatpostdate is what you should use on your templates now.

In beta5, formatpostdate will use what you send in the dateformat param of your News tag ({cms_module module='news' dateformat='%Y %b %d'}).  However, I think I'm going to go one step further and have that look for locale settings if dateformat isn't given (which is dateformat='%x').
pinthenet

Re: setlocale and news etc

Post by pinthenet »

Just tried again, defining the dateformat in the content as in your example, but I still get english month abbreviations. I just tried the %x format and I still get 'en_US' (mm/dd/yy). I have locale='de_DE' in config.php. Where else can I control the locale?
pinthenet

Re: setlocale and news etc

Post by pinthenet »

I finally found what I was looking for (?) here http://forum.cmsmadesimple.org/index.ph ... 550.0.html

I added the more complex statement
setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de-DE', 'de', 'ge', 'de_DE.ISO_8859-1', 'German');
right at the start of the news module and I got German months.....

It seems that just 'de_DE' isn't enough

I noticed that  the format was then correct for (eg) Events, even though I don't have a setlocale there - I presume it's persisting.

As a test I transferred the setlocale to the start of config.php and that works too and I assume it's more global?

John
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: setlocale and news etc

Post by Ted »

Yeah, I believe that setlocale works for the duration of the request.  Interesting that it took that amount of stuff to get it to work properly.  I'm not sure what the proper way of handling that is...
Locked

Return to “CMSMS Core”