Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Blog: Date translation


Go to End


3 Posts   2826 Views

Avatar
masson

Community Member, 8 Posts

3 June 2008 at 4:00am

Hey,

i can´t seem to figure out how to translate the dates in the blog system. Such as Browse by Date "May 2008", i would need to translate "May".

Are you using phpsetlocale?, if so is there any other way i can translate this since i don´t have the spanish locale installed and can´t install it.

Thanks a lot!. I appreciate all help.

Avatar
cliersch

Community Member, 75 Posts

4 June 2008 at 1:02am

Edited: 04/06/2008 1:04am

Hi masson!
I solved the problem by adding and changing the folowing code in the sapphire/core/model/fieldtypes/Date.php file:

function Format($formattingString) {

if($this->value) return date($formattingString, strtotime($this->value));

function FormatDate($format) {

if ($this->value) $mydate = strftime($format, strtotime($this->value));

return utf8_encode($mydate);

Call the function width $Date.FormatDate(%B %Y).

That should work out!
Caution: To see other languages the setlocal for the language must be installed on your server!

the _config.php needs this to use it (for German e.g.):
i18n::set_locale('de_DE');
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');

Avatar
Juanitou

Community Member, 323 Posts

2 November 2008 at 1:52pm

Thats nice! Thank you very much. You should submit it to the developers...