Skip to content

Instantly share code, notes, and snippets.

@yanknudtskov
Created May 3, 2019 20:28
Show Gist options
  • Save yanknudtskov/15e8c785b4ec6d5c08751d580c15a4df to your computer and use it in GitHub Desktop.
Save yanknudtskov/15e8c785b4ec6d5c08751d580c15a4df to your computer and use it in GitHub Desktop.
Overriding specific language/translations in WordPress
<?php
add_filter( 'gettext', 'yanco_filter_gettext', 10, 3 );
function yanco_filter_gettext( $translated, $original, $domain ) {
// Use the text string exactly as it is in the translation file
if ( $translated == '' ) {
$translated = '';
}
return $translated;
}
add_filter( 'gettext_with_context', 'yanco_filter_gettext_with_context', 10, 4 );
function yanco_filter_gettext_with_context( $translated, $original, $context, $domain ) {
// Use the text string exactly as it is in the translation file
if ( $translated == '' ) {
$translated = '';
}
return $translated;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment