Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active December 23, 2015 20:49
Show Gist options
  • Select an option

  • Save joshfeck/6692569 to your computer and use it in GitHub Desktop.

Select an option

Save joshfeck/6692569 to your computer and use it in GitHub Desktop.
fork of another gettext filter function.
function myvoucher_filter_gettext( $translated, $original, $domain ) {
// This is an array of original strings
// and what they should be replaced with
$strings = array(
'Enter Voucher code:' => 'Enter Groupon code:',
// Add some more strings here
);
// See if the current string is in the $strings array
// If so, replace it's translation
if ( isset( $strings[$original] ) ) {
// This accomplishes the same thing as __()
// but without running it through the filter again
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'myvoucher_filter_gettext', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment