I have a WordPress multisite, which is in both english and french. On the french site, localization is working great (using date_l18n()
for dates, and __()
, etc. for the rest).
When an AJAX call sends off to WP and returns data (the same rendering functions being called from initial page load and AJAX), however, they are returning English date values.
Example: Date archive says “septembre 2013”. You click the Next Month button, which sends off to AJAX and returns the new month header, and article listing. It’s returning “October 2013” rather than “octobre 2013”.
Is this a known bug, or should I be submitting this to track?
function render_event_archive_month_header( $date = null, $echo = true ) {
$date_str = strtotime( $date );
if( ! $echo )
ob_start();
<?php echo date_i18n('F Y', $date_str ); ?>
<?php
if( ! $echo ) {
$data = ob_get_contents();
ob_end_clean();
return $data;
}
}
This is being passed a yyyy-mm-dd date value, like so
render_event_archive_month_header( '2013-10' );
from within my Ajax action callback.
1 Answer
Thank you for all the help Toscho! The issue was actually quite obvious after a night of sleep. I am using WP Native Dashboard. In case you don’t know what that is, it allows you to change the language of the Admin section of the site.
Considering WP Ajax is considered to be admin, it’s changing the language like so. Once I logged out, or changed the back end language to FR, it’s working as intended.
I’ll report this to the plugin author as a bug.