I recently used this bit of code to translate the WooCommerce bits that other translation plugin didn't pick up - however, this code doesn't seem to work on some strings like this one. Any idea why it doesn't work?
Loco translate didn't work on this one, and while the filter code was working on 95% of other untranslated strings, this one remained stubborn.
// Alter WooCommerce View Cart Text
add_filter( 'gettext', function( $translated_text ) {
if ( 'You may also like…' === $translated_text ) {
$translated_text = 'To moze Ci sie spodobac';
}
return $translated_text;
} );
You can use
woocommerce_product_upsells_products_headingrelated available filter hook:Or your revised code (where "…" character requires being replaced with
…):Code goes on functions.php file of your child theme (or in a plugin). Both ways work.