-
AuthorPosts
-
October 27, 2015 at 3:28 pm #642149
Hi,
I’ve encountered the following fatal error :
Fatal error: Cannot redeclare translate_search_string() (previously declared in /home/content/p3pnexwpnas02_data02/31/2723131/html/wp-content/themes/x-child/functions.php:28) in /home/content/p3pnexwpnas02_data02/31/2723131/html/wp-content/themes/x-child/functions.php on line 38
Can you please help?
Thanks,
Julie
October 27, 2015 at 3:53 pm #642190Hello Julie,
Thanks for writing in!
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thanks.
October 27, 2015 at 4:55 pm #642300This reply has been marked as private.October 27, 2015 at 9:17 pm #642515Hello Julie,
It would be best if we can see the content of your functions.php file. Based on the error you have multiple declaration of this function
translate_search_string()
. Can you also give us a copy of the code you’ve added so we can check it on our setup?You can always ask to revert them to a previous working version.
October 27, 2015 at 9:54 pm #642540This reply has been marked as private.October 28, 2015 at 12:27 am #642697Hello There,
Thank you for giving us the code.
Please update the code to this:add_filter( 'gettext', 'translate_search_string', 20, 3 ); function translate_search_string( $translated_text, $text, $domain ) { if ( $text == 'Read More' ) return __( 'Lire la suite', $domain ); else if ( $text == 'Leave a comment' ) return __( 'Ajouter un commentaire', $domain ); else return $translated_text; }
Hope this helps.
October 28, 2015 at 10:03 am #643250Hello. Thank you for providing the code. I was able to fix the problem with my hosting provider. However, the code to translate Leave a Comment on posts doesn’t work. Should I be adding the code to a different php file? thanks!
October 28, 2015 at 12:32 pm #643495Hi There,
Please update the previous code a bit:
add_filter( 'gettext', 'translate_search_string', 20, 3 ); function translate_search_string( $translated_text, $text, $domain ) { if ( $text == 'Read More' ) return __( 'Lire la suite', $domain ); else if ( $text == 'Leave a Comment' ) return __( 'Ajouter un commentaire', $domain ); else return $translated_text; }
The English text is Leave a Comment, not Leave a comment.
Hope it helps 🙂
October 30, 2015 at 9:00 am #646288Awesome, it works! If there are other text entries I’d like to translate, should I do it like this:
function translate_search_string( $translated_text, $text, $domain ) {
if ( $text == ‘Read More’ ) return __( ‘Lire la suite’, $domain );
else if ( $text == ‘Leave a Comment’ ) return __( ‘Ajouter un commentaire’, $domain );
else if ( $text == ‘Submit’ ) return __( ‘Envoyer’, $domain );
else return $translated_text;
}Also, how can I translate the tooltips when hovering on an link?
October 30, 2015 at 11:23 am #646467This reply has been marked as private.October 30, 2015 at 12:53 pm #646570Hi there,
Thanks for writing in!
You need to use fr_FR as it’s selected in your site (see: http://prntscr.com/8x55am).
In regard to your earlier question, yes you can translate more strings using
else if
conditional.Thank you!
-
AuthorPosts