Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #868203

    venya
    Participant

    Hello!
    I’m trying to translate a few things on the cart page. Using Polylang plugin, site English/Russian.

    I used poedit to add a ru_ru.po file.
    Some of the terms were not on the list and so I need to still translate.
    They are: Product, Quatity, Total, Coupon Code (inside entry box) Apply Coupon (button), Update Cart(button).

    I got it to change using the following code in functions. However, this translated the words on both language pages. How do I limit it to just change on my russian cart page?

    Thank you.

    add_filter(‘gettext’, x_translate_text , 20, 3);
    function x_translate_text ( $translated_text, $text, $domain ) {

    $translation = array (
    ‘Product’ => ‘Книги’,
    ‘Price’ => ‘Цена’,
    ‘Quantity’ => ‘Количество’,
    ‘Total’ => ‘Итоговая Цена’,
    ‘Apply Coupon’ => ‘Janos!’,
    );
    if( isset( $translation[$text] ) ) {
    return $translation[$text];
    }
    return $translated_text;
    }

    or:
    add_filter(‘gettext’, ‘translate_update_cart’ );
    function translate_update_cart($translated) {
    $translated = str_ireplace(‘Update Cart’, ‘Update Cart RUSSKI’, $translated);
    return $translated;
    }

    #868205

    venya
    Participant
    This reply has been marked as private.
    #868977

    Zeshan
    Member

    Hi Venya,

    Thanks for writing in!

    As this is related to a 3rd party plugin, we cannot provide support for 3rd party plugins or scripts. That said, I could point you in the right direction with the understanding that it would ultimately be your responsibility to take it from here.

    Try using this code instead:

    <?php
    
    add_filter('gettext', 'x_translate_text', 20, 3);
    function x_translate_text ( $translated_text, $text, $domain ) {
    
      if ( get_locale() == 'ru_RU' ) {
        $translation = array (
        'Product' => 'Книги',
        'Price' => 'Цена',
        'Quantity' => 'Количество',
        'Total' => 'Итоговая Цена',
        'Apply Coupon' => 'Janos!',
        );
        if( isset( $translation[$text] ) ) {
          return $translation[$text];
        }
      }
    
      return $translated_text;
    }
    

    Thank you!

    #869557

    venya
    Participant

    I got it to work. Thank you so much for your help!!

    As always, Themeco support has been fantastic!

    #869899

    Christopher
    Moderator

    Thank you for your kind words 🙂 Always happy to be able to help.