Translating cart page with add_filter in functions.php

[ad_1]

I need to translate the products, cart, and checkout.

I tried to add custom code to functions.php but this error popped out:
“Unable to communicate back with the site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.”

This is the code I imported:

add\_filter( ‘gettext’, ‘ahirwp\_translate\_woocommerce\_strings’, 999, 3 );

function ahirwp\_translate\_woocommerce\_strings( $translated, $untranslated, $domain ) {

if ( ! is\_admin() && ‘woocommerce’ === $domain ) {

switch ( $translated ) {

case ‘Sale!’:

$translated = ‘On Offer’;

break;

case ‘Description’:

$translated = ‘Product Specifications’;

break;

// ETC

}

}

return $translated;

}

If you know a simpler solution please help me…

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer