Skip to content

Instantly share code, notes, and snippets.

@Willem-Siebe
Last active September 8, 2016 11:12
Show Gist options
  • Save Willem-Siebe/5eb063c04dda7b6863e8 to your computer and use it in GitHub Desktop.
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/.
// 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 );
@Willem-Siebe
Copy link
Author

Checked for updates and changed the gist, see https://wpml.org/forums/topic/how-to-translate-the-date-format/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment