How to translate Date Formats on Drupal 7? -
on admin/config/regional/date-time/formats can set date formats, m js, , map them date types on admin/config/regional/date-time, "short format date".
now want set multilanguage website, not have translate month or week names itself, choose different date format based on language. is, apr 12th ok on english, translating apr abr won't make better on spanish: abr 12th --should 12 abr. need translate format itself, instead of m js, spanish version of website use j m.
how can achieve this? tried searching on admin/config/regional/translate/translate these date formats. apr->abr part covered there, not format itself. can't find strings m js , so.
you can use drupal 7 t() function: http://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/t/7
anything goes through t() function has manually translated in back-end configuration > regional , language > translate interface. means you'll have manually put in translations days , months.
sample code:
<?php global $language; $day = t(date('l')); $month = t(date('f')); $daynum = date('j'); $year = date('y'); $output = t('@day, @month @daynum, @year', array( '@day' => $day, '@month' => $month, '@daynum' => $daynum, '@year' => $year )); print ("<p class='today'>".$output."</p>"); ?>
Comments
Post a Comment