Skip to content

Instantly share code, notes, and snippets.

@bhays bhays/WP-Translate-Strings
Last active Dec 20, 2015

What would you like to do?
Translate selected strings in WordPress. Originally from
// 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
You can’t perform that action at this time.