How to prepare SimplePie_Item’s get_date() for l10n?

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

Leave a Comment