• Resolved tarantinobcn

    (@tarantinobcn)


    Hello!
    I need to translate the button that appears in the dropdown of the search bar. (read more)

    I have managed to translate it using the Loco Translate plugin, but however, in the products where I have hidden the price using the ELEX WooCommerce Role Based Pricing plugin, the text is not translated.

    In this video you can see that the text is translated for products with a price, but not for products with a hidden price.

    https://www.amazon.es/photos/share/1BSEWZHR6sxcccpK6knx09d2C6yRnuE8lXNCOd5o0GM

    Do you know how I can fix this?
    Thank you very much!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Kris

    (@c0nst)

    Hi @tarantinobcn

    You can use this code snippet to translate any text to a custom value:

    // Translate Read more to custom text
    add_filter( 'gettext', function ( $translated_text, $text, $domain ) {
    	if ( ! is_admin() && $domain === 'woocommerce' && $translated_text === 'Read more' ) {
    		$translated_text = 'Leer Más';
    	}
    	return $translated_text;
    }, 20, 3 );

    You have two ways to add this code to your theme:

    1. Open the functions.php in your child theme and add the code at the end.
    2.  or install the Code Snippets plugin and apply this code as a snippet.

    Regards,
    Kris

    Thread Starter tarantinobcn

    (@tarantinobcn)

    Hello!
    Thank you very much for the attempt, but unfortunately it didn’t work.

    I pasted the code using , but it still doesn’t translate.

    Is there anything else I can do to fix it?

    Thank you very much!

    https://ibb.co/tM1WN2V

    Plugin Support Kris

    (@c0nst)

    Hi @tarantinobcn

    Make sure you checked this code in incognito mode or on a non-admin account. There is a special condition in the code that disabled this for admin. I think you can delete it. Try the below code with only 1 condition that searches for “Read more” text only and translates it.

    // Translate Read more to custom text
    add_filter( 'gettext', function ( $translated_text, $text, $domain ) {
    	if ( $translated_text === 'Read more' ) {
    		$translated_text = 'Leer Más';
    	}
    	return $translated_text;
    }, 20, 3 );

    Regards,
    Kris

    Thread Starter tarantinobcn

    (@tarantinobcn)

    Hello Kris!

    I have changed the code but it still doesn’t work. I’ve tried with different accounts and different roles, but it doesn’t work, it still appears in English.
    I don’t know what could be happening.
    What can I do?
    Thank you very much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘button translation’ is closed to new replies.