I have a WP homepage with 2 languages and use the Polylang plugin to do that; so far so good.
Now I have an US theme installed which provides the blog articles only with US date format (like "28 September, 2017"). Unfortunately, Polylang only translates the month names correctly but does not change the date format as such.
The theme's blog php file uses:
get_the_time('d F, Y')
If I change that format manually into the local date format it will apply it for the English version too which of course does not make sense. Instead, I want to hook into the functions.php file and get Polylang to change the date format generally according the language of the page.
I found this snippet for WPML (another WP multilanguage plugin) which should do the trick:
add_filter( 'option_date_format', function( $format ) {
do_action( 'wpml_register_single_string', 'Date formats', 'Date format', $format );
return apply_filters( 'wpml_translate_single_string', $format, 'Date Formats', 'Date format' );
} );
add_filter( 'option_time_format', function( $format ) {
do_action( 'wpml_register_single_string', 'Date formats', 'Time format', $format );
return apply_filters( 'wpml_translate_single_string', $format, 'Date Formats', 'Time format' );
} );
Unfortunately, I do not manage to do it for Polylang. I know the function to use is:
pll_register_string( $name, $string, $group, $multiline );
See: https://polylang.pro/doc/function-reference/#pll_register_string
Does somebody know how to do this?