Last active
September 8, 2016 11:12
-
-
Save Willem-Siebe/5eb063c04dda7b6863e8 to your computer and use it in GitHub Desktop.
Translate Date format multilangual website using WPML, see http://wpml.org/forums/topic/date-formatting-issue/.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Translate Date format multilingual website using WPML, see https://gist.github.com/Willem-Siebe/5eb063c04dda7b6863e8. | |
/** | |
* WPML and Toolset Support Team. | |
* Register date_format option in string translations. | |
* | |
* @param string $format Initial format stored in database. | |
* | |
* @return string Translated format. | |
*/ | |
function wsis_translate_date_format( $format ) { | |
// Register date format for String Translation. | |
do_action( 'wpml_register_single_string', 'Date Formats', $format, $format ); | |
// Get translated version of date format. | |
$format = apply_filters( 'wpml_translate_single_string', $format, 'Date Formats', $format ); | |
return $format; | |
} | |
add_filter( 'option_date_format', 'wsis_translate_date_format', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Checked for updates and changed the gist, see https://wpml.org/forums/topic/how-to-translate-the-date-format/.