Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to improve the localization of the Bones theme. On the admin side it provides an RSS widget which uses the following code:

<?php
   echo $item->get_date('j F Y @ g:i a');
?>

This uses SimplePie, here's the doc for the method. Which would be the best way to make this translatable?

share|improve this question
add comment

2 Answers

What do you think about this one?

<?php 
    echo mysql2date(__('j F Y @ g:i a', 'bonestheme'), $item->get_date('Y-m-d H:i:s')); 
?>
share|improve this answer
add comment

Best way would probably be to use the built in Internationalization function in WordPress. This will then translate according to the language pack being used.

The "U" character to a date() call gives the unix timestamp, which is just what you need in this case, for passing to date_i18n().

For example: echo date_i18n('j F Y @ g:i a', $item->get_date('U'));

The months and such will be translated accordingly. If you want to add the __() wrapper around the date format string, that will work just as well.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.