Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Blog: Date translation

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

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

Page: 1
Go to End
Author Topic: 2422 Views
  • masson
    Community Member
    8 Posts

    Blog: Date translation Link to this post


    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.

  • cliersch
    Community Member
    75 Posts

    Re: Blog: Date translation Link to this post

    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.):
    setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');

  • Juanitou
    Community Member
    323 Posts

    Re: Blog: Date translation Link to this post

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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.