Page 1 of 1
International dates
Posted: Tue Jan 18, 2005 7:05 pm
by plank
Is there any way to change the language of the date-display in the News module?
I've got my CMS installed on a webserver in the US, but I need the dates to be in swedish.
The coolest way would probably be to somehow make a user defined tag like {locale_sv} that you could put in a template to make the date display in the right language.
Then you could put other locale-tags on other pages to make a 'sort-of' multi-language site.
Or maybe not.

International dates
Posted: Tue Jan 18, 2005 7:16 pm
by Ted
{cms_module module='news' dateformat='Y.m.d'}
Date format is based on the php
date function.
International dates
Posted: Tue Jan 18, 2005 7:34 pm
by plank
Thanks for the quick reply.
Yes, I tried manipulating the date-format a bit and I guess it would work to just use numbers instead of month names in the date.
But ideally I'd like to have the right names for days and months in the date. Like Monday 10 July would become MÃ¥ndag 10 Juli on a swedish page.
I tried sneaking in a setlocale() in one of the news-module scripts but that didn't work. Admittedly I didn't really know what i was doing.
Hmm, perhaps I could change it with som Smarty-stuff...
International dates
Posted: Tue Jan 18, 2005 7:42 pm
by Ted
I'm sure there is a way to do it pretty easily... I've just never messed with it before. locale is one thing I've been lucky enough to stay away from with php.
International dates
Posted: Tue Jan 18, 2005 11:31 pm
by plank
Ah, I figured it out.
The problem is that .date doesn't respond to setlocale. So I changed it to .strftime (and adjusted the format string) in the news-script.
And after that it was easy to add a setlocale(lc_time, sv_SE); in a tag to the top of the news-page and presto, swedish names!
Hopefully I didn't break something else by doing that.

Re: International dates
Posted: Sun Mar 13, 2005 9:20 pm
by Krol
@plank:
Could you please tell me the lines you had to edit?
- Krol
Re: International dates
Posted: Thu Mar 31, 2005 11:49 am
by matt
Look for ".date" (without quotation marks) in News.module.php and replace it with ".strftime". There should be two of them.
Then set locale somewhere in the same file. I added:
Code: Select all
if (isset($params["locale"]))
{
setlocale(LC_ALL, $params["locale"] );
}
in line 298 (after all other parameters are checked).
I can now set the locale with this additional parameter when using the news module in my templates. You can use LC_TIME instead of LC_ALL.
By the way: that's a mess. I had to set the locale to "plk" to get the polish locale on Windows and to "pl_PL" to get it to work on *nix. Why do they always have to do everything their own way at MS?
Re: International dates
Posted: Fri Sep 16, 2005 11:52 am
by saltydog
matt wrote:
Look for ".date" (without quotation marks) in News.module.php and replace it with ".strftime". There should be two of them.
Can't find those lines ( .date ) into the module!