Page 1 of 1
setlocale and news etc
Posted: Tue Nov 22, 2005 9:11 am
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
Re: setlocale and news etc -story so far
Posted: Tue Nov 22, 2005 7:30 pm
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
Re: setlocale and news etc
Posted: Wed Nov 23, 2005 10:47 am
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').
Re: setlocale and news etc
Posted: Wed Nov 23, 2005 5:20 pm
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?
Re: setlocale and news etc
Posted: Wed Nov 23, 2005 8:28 pm
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
Re: setlocale and news etc
Posted: Thu Nov 24, 2005 2:21 am
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...