Ecommerce Shopify WordPress Discussion

Translate WooCommerce products sorting options

I am trying to translate Woocommerce product sorting to the language of my country from the original english version. Unfortunately it is working only partly, the text "Sort by" just can not be translated. What I consider as a best option, I decided to edit the text using functions.php file in my Avada theme. As I mentioned, there is only a part of a working code even if I use the same method (you can find it below). function woosuite_change_cart_totals_text( $translated_text, $text, $domain ) { if ( $text === 'Default Order' ) { $translated_text = 'Výchozí'; } if ( $text === 'Name' ) { $translated_text = 'Jméno'; } if ( $text === 'Popularity' ) { $translated_text = 'Oblíbené'; } if ( $text === 'Sort by ' ) { $translated_text = 'Řadit dle '; } return $translated_text; } add_filter( 'gettext', 'woosuite_change_cart_totals_text', 20, 3 ); What is translated after this is visible in this screenshot. The text "Sort by " contains a space but I was trying to change without and still not working. It will translate everything without text "Sort by ". Another attempt what I tried is also below (also not working): add_filter('woocommerce_catalog_orderby', 'wc_customize_product_sorting'); function wc_customize_product_sorting($sorting_options){ $sorting_options = array( 'menu_order' => __( 'Řazení', 'woocommerce' ), 'popularity' => __( 'Oblíbenost', 'woocommerce' ), 'price' => __( 'Cena: od nejnižší', 'woocommerce' ), 'price-desc' => __( 'Cena: od nejvyšší', 'woocommerce' ), ); return $sorting_options; } The same case is with the numbered of shown products (pagination). Thank you for any help!
To translate the sorting options, you can use one of the following code replacement instead: function translate_catalog_orderby_strings2( $orderby ) { if ( isset($orderby['menu_order']) ) { $orderby['menu_order'] = 'Výchozí řazení'; // 'Default sorting' } if ( isset($orderby['popularity']) ) { $orderby['popularity'] = 'Řadit dle oblíbené'; // 'Sort by popularity' } if ( isset($orderby['rating']) ) { $orderby['rating'] = 'Řadit dle průměrné hodnocení'; // 'Sort by average rating' } if ( isset($orderby['date']) ) { $orderby['date'] = 'Řadit dle nejnovější'; // 'Sort by latest' } if ( isset($orderby['price']) ) { $orderby['price'] = 'Řadit dle cena: nízká až vysoká'; // 'Sort by price: low to high' } if ( isset($orderby['price-desc']) ) { $orderby['price-desc'] = 'Řadit dle cena: vysoká až nízká'; // 'Sort by price: high to low' } return $orderby; } Or also: add_filter( 'gettext', 'translate_catalog_orderby_strings', 10, 3 ); function translate_catalog_orderby_strings( $translated_text, $text, $domain ) { if ( is_admin() ) { return $translated_text; } if ( $text === 'Default sorting' ) { $translated_text = 'Výchozí řazení'; } elseif ( $text === 'Sort by popularity' ) { $translated_text = 'Řadit dle oblíbené'; } elseif ( $text === 'Sort by average rating' ) { $translated_text = 'Řadit dle průměrné hodnocení'; } elseif ( $text === 'Sort by latest' ) { $translated_text = 'Řadit dle nejnovější'; } elseif ( $text === 'Sort by price: low to high' ) { $translated_text = 'Řadit dle cena: nízká až vysoká'; } elseif ( $text === 'Sort by price: high to low' ) { $translated_text = 'Řadit dle cena: vysoká až nízká'; } return $translated_text; } Code goes on functions.php file of your child theme (or in a plugin). Tested and works.

February 17, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.