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.
date_i18n()
?$GLOBALS['wp_locale']
?'en_US' === get_locale() or load_default_textdomain();
in your AJAX callback. If that doesn’t work, the language is not detected correctly.