2

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?

2

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.

0

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')); 
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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