Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1176544
    Rich H
    Participant

    I swear that all the text was translated and with an update some things got reverted back to english. Everything in the PO MO files is translated but its not showing on the front end.

    I found this bit of code in the forums, and it worked for Comments, but not the other terms.

    add_filter('ngettext', 'translate_text' );
    function translate_text($translated) { 
      $translated = str_ireplace('Comment', 'Commentaire', $translated);
      $translated = str_ireplace('Comments', 'Commentaire', $translated);
      $translated = str_ireplace('Submit', 'Soumettre', $translated);
      $translated = str_ireplace('Search', 'Recherche', $translated);
      return $translated; 
    }

    https://designinterieur.com/le-design-un-investissement-rentable/ The search box on the top right, and Submit at the bottom.

    Thanks.

    #1176625
    Darshana
    Moderator

    Hi there,

    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 credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #1176721
    Rich H
    Participant
    This reply has been marked as private.
    #1177338
    Rad
    Moderator

    Hi there,

    Please try this

    add_filter('gettext', 'translate_text', 20, 3 );
    
    function translate_text($translated_text, $text, $domain) { 
    
    $translations = array (
    
    'Comment' => 'Commentaire',
    'Comments' => 'Commentaire',
    'Submit' => 'Soumettre',
    'Search' => 'Recherche'
    
    );  
    
    return isset( $translations[ $text ] ) ? $translations[ $text ] : $translated_text; 
    
    }

    Hope this helps.

    #1178139
    Rich H
    Participant

    Partially there, the ‘comments’ does not translate with the above code, but the other 2 do.

    #1178721
    Rad
    Moderator

    Hi there,

    Please try this,

    add_filter('gettext', 'translate_text', 20, 3 );
    
    function translate_text($translated_text, $text, $domain) { 
    
    $translations = array (
    
    'Comment' => 'Commentaire',
    'Comments' => 'Commentaire',
    '%s Comment' => '%s Commentaire',
    '%s Comments' => '%s Commentaire',
    'Submit' => 'Soumettre',
    'Search' => 'Recherche'
    
    );  
    
    return isset( $translations[ $text ] ) ? $translations[ $text ] : $translated_text; 
    
    }

    Cheers!

    #1181340
    Rich H
    Participant

    Still no 🙁 Doesn’t translate comments.

    #1181355
    Thai
    Moderator

    Hi There,

    Please keep your code and also add the following code:

    add_filter('ngettext', 'x_translate_comments' , 20, 3);
    function x_translate_comments( $translated_text, $single, $plural ) {
    
    	$translation = array(
    		'%s Comment'      => '%s Commentaire',
    		'%s Comments'     => '%s Commentaire'
    	);
    
    	if( isset( $translation[$single] ) ) {
    		return $translation[$single];
    	}
    	if( isset( $translation[$plural] ) ) {
    		return $translation[$plural];
    	}
    	return $translated_text;
    }

    Hope it helps 🙂

    #1181548
    Rich H
    Participant

    AWESOME, thanks.

    #1181557
    Rahul
    Moderator

    Glad we were able to help you out!

    If you have anything further to ask, let us know. We’d be happy to assist you with anything.

    Thanks for using the X.

  • <script> jQuery(function($){ $("#no-reply-1176544 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>