Tagged: x
-
AuthorPosts
-
April 5, 2016 at 4:19 pm #868203
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;
}April 5, 2016 at 4:20 pm #868205This reply has been marked as private.April 6, 2016 at 5:50 am #868977Hi 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!
April 6, 2016 at 10:55 am #869557I got it to work. Thank you so much for your help!!
As always, Themeco support has been fantastic!
April 6, 2016 at 2:10 pm #869899Thank you for your kind words 🙂 Always happy to be able to help.
-
AuthorPosts