string translation in functions.php not working


I used the following code in functions.php to translate some text:

add_filter('gettext', 'aad_translate_words_array');
add_filter('ngettext', 'aad_translate_words_array');
function aad_translate_words_array( $translated ) {
     $words = array(
        // 'word to translate' = > 'translation'
        'Place Name' => 'Artist Name',
        'Add Your Place' => 'Add Your Artist Practice'
     $translated = str_ireplace(  array_keys($words),  $words,  $translated );
     return $translated;

This code is not producing any text changes.

Why is this the case? Help appreciated.

Steve 2 months 0 Answers 13 views 0

Leave an answer