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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   2994 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...