Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #153650

    Minstedpc
    Participant

    Hello everyone, I’ve tried a lot to translate the line “I’ve read and accept the terms & conditions” in the checkout page and I haven’t been able to do so, I’ve tried the following code I saw in another page and it didn’t work (put it in the functions php of my child theme.

    add_filter('gettext', 'translate_text');
    add_filter('ngettext', 'translate_text');
    function translate_text($translated) {
    $translated = str_ireplace('Billing Details', 'Detalles de compra', $translated);
    $translated = str_ireplace('I’ve read and accept the', 'He leido y aceptado expresamente los', $translated);
    $translated = str_ireplace('terms & conditions', 'términos y condciones', $translated);
    return $translated;
    #153972

    Rad
    Moderator

    Hi there,

    Thanks for posting in.

    Have you tried using a translation plugin like WPML? You could use their manual string translation.

    Or this,

    add_filter ('gettext', 'x_translate_text', 99, 3 );
    
    function x_translate_text ( $translated_text, $text, $domain ) {
    
    $translation = array (
    'Billing Details' => 'Detalles de compra',
    'I\'ve read and accept the terms & conditions' => 'He leido y aceptado expresamente los términos y condciones'
    );
    
    if( isset( $translation[$text] ) ) {
    return $translation[$text];
    }
    
    return $translated_text;
    
    } 

    The $translation = array() contains the original string and the translation string. The original string should match the extract string you wish to translate. Any space or mismatched characters will invalidate the translation.

    Hope this helps.

    #156820

    Minstedpc
    Participant

    Hello, Ive tried your solution but it didn’t work, does it go on the childtheme funcitions.php or where?

    #157038

    Nabeel A
    Moderator

    Hi there,

    You’ll need to place the given code in your child theme’s functions.php file. Also did you install the WPML plugin?

    #204586

    Minstedpc
    Participant

    Hello, your solution worked until tonights update, what can i do? Thanks in advance!

    #205326

    Nico
    Moderator

    Hi there,

    Did it alter the any changes with your child theme funcitions.php? or was it a WPML compatibility issue?

    if nothing was altered or you did not use the WPML, you could try clearing your cache if it helps.

    Hope it works. if not let us know.

    Thanks.

    #206668

    Minstedpc
    Participant

    Hello, here is how I have it added in my childrens theme functions.php

    add_filter ('gettext', 'x_translate_text', 99, 3 );
    
    function x_translate_text ( $translated_text, $text, $domain ) {
    
    $translation = array (
    
    'Billing Details' => 'Detalles de compra',
    
    'I’ve read and accept the ' => 'He leido y aceptado expresamente los términos y condiciones'
    
    );
    
    if( isset( $translation[$text] ) ) {
    
    return $translation[$text];
    
    }
    
    return $translated_text;
    
    }
    

    I’ve cleared the cache and this doesn’t work still, I don’t get it either why it stopped working! Thanks for your help!

    #206680

    Minstedpc
    Participant

    Sorry I forgot to say I don’t use WPML.

    #207155

    Rad
    Moderator

    Hi there,

    Please use the exact code given 🙂

    Please observe this :

    $translation = array (
    'Billing Details' => 'Detalles de compra',
    'I\'ve read and accept the terms & conditions' => 'He leido y aceptado expresamente los términos y condciones'
    );

    Thanks!

    #214174

    Minstedpc
    Participant

    Hello, I tried with the complete code, with the exact code and still doesn’t work, here is the code:

    add_filter ('gettext', 'x_translate_text', 99, 3 );
    
    function x_translate_text ( $translated_text, $text, $domain ) {
    
    $translation = array (
    'Billing Details' => 'Detalles de compra',
    'I\'ve read and accept the terms & conditions' => 'He leido y aceptado expresamente los términos y condiciones'
    );
    
    if( isset( $translation[$text] ) ) {
    return $translation[$text];
    }
    
    return $translated_text;
    
    } 

    What could the problem be?

    #214767

    Zeshan
    Member

    Hi there,

    In that case, 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.

    Thank you.

    #221374

    Minstedpc
    Participant
    This reply has been marked as private.
    #221806

    Rad
    Moderator

    Hi there,

    Please check now, it’s translated.

    Cheers!

    #221844

    Minstedpc
    Participant

    Thanks you are awesooome!

    #222135

    Christopher
    Moderator

    Thanks for kind words and you’re welcome.