Translating APPLY COUPON

Hi there,

I have a site here at:

http://consteach.com/cart/

And I’m trying to translate the APPLY COUPON btn. For which, I’m trying to use this code:

add_filter( 'gettext', 'translate_x_strings', 20, 3 );

function translate_x_strings( $translated_text, $text, $domain ) {

        switch ( $translated_text ) {

            case 'Apply coupon' :
            case 'Apply Coupon' :

                $translated_text = __( 'Your translated text.', '__x__' );
                break;

        }

    return $translated_text;
}

And it is not working. Could you help?

Thanks a bunch!

Hi @Pbalazs89,

Thanks for reaching out.

It should be translatable but I’m not currently sure the reason why it’s not. Would you mind providing your admin login credentials for further checking?

And your cart URL is dead, I assume you have changed the URL.

Thanks!

Sure thing! Added a login to my last comment. Yes I did manage to update the cart page!

Thanks for looking into it!

Hi @Pbalazs89,

Thanks, but please provide us FTP credential as well so we can test.

Cheers!

Hi, added the ftp credentials as well!!

Hey @Pbalazs89,

This is the correct code:

  add_filter( 'gettext', 'translate_x_strings', 20, 3 );

  function translate_x_strings( $translated_text, $text, $domain ) {
  
          switch ( $translated_text ) {
  
              case 'Apply Coupon' :
  
                  $translated_text = esc_attr__( 'test', '__x__' );
                  break;
  
          }
  
      return $translated_text;
  }

Hope that helps.

Thanks a bunch!

Sorry, but where did you add the code exactly? I’m trying to add it in Theme Options, but it’s overwritten by yours.

Thanks!

Hello @Pbalazs89,

Thanks for updating the thread. :slight_smile:

Please take a look into Child Theme function.php file which you can find under /wp-content/themes/pro-child/ folder or under Appearance > Theme editor.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.