Skip to content

Instantly share code, notes, and snippets.

@bhays
Last active December 20, 2015 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhays/6136951 to your computer and use it in GitHub Desktop.
Save bhays/6136951 to your computer and use it in GitHub Desktop.
Translate selected strings in WordPress. Originally from http://www.viper007bond.com/2011/07/13/changing-core-wordpress-strings/
// Translate theme strings
function mytranslate_filter_gettext( $translated, $original, $domain ) {
// Array of original strings and what they should be replaced with
$strings = array(
'Contribute Now' => 'Donate Now',
);
if ( isset( $strings[$original] ) ) {
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'mytranslate_filter_gettext', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment