WooCommerce translation strings

Untranslated WooCommerce strings in Cart and Checkout pages

Learn how to translate WooCommerce strings like Update Cart and I’ve read and accept the terms & conditions which remain untranslated after plugin update. In my case French language is the primary WordPress language (no additional languages are  being used hence no Loco nor WPML plugins are installed) and the strings like Product, Price, Quantity, Total, Coupon code, Apply Coupon and Update Cart, which appear on the Cart page, still remain in English. Moreover, on the next step the string “I’ve read and accept the terms & conditions” also appears in English.

Since I don’t use any localization plugin for this project and all official language files are already in place, I had to find a workaround for those stubborn strings. For the first step and strings on the Cart page I modified the theme’s functions.php file to manually translate the English strings.

1. Locate and edit the functions.php file

The file is located in /wp-content/themes/YOUR-THEME-NAME/
Open it for editing and at the bottom place the following code:

add_filter('gettext', 'translate_strings');
add_filter('ngettext', 'translate_strings');
function translate_strings($translated) {
$translated = str_ireplace('Apply coupon', 'Appliquer le coupon', $translated);
return $translated;

If you have only one string to translate this should be enough, just change the words Apply Coupon and Appliquer le coupon accordingly to your language (this is applicable for any other string as well).

Translate WooCommerce strings

However, if you need to translate more than one string then the code should look something like this:

add_filter('gettext', 'translate_strings');
add_filter('ngettext', 'translate_strings');
function translate_strings($translated) {
$translated = str_ireplace('Coupon code', 'Code coupon', $translated);
$translated = str_ireplace('Apply Coupon', 'Appliquer le coupon', $translated);
$translated = str_ireplace('Update Cart', 'Mise à Jour', $translated);
$translated = str_ireplace('PRODUCT', 'PRODUIT', $translated);
$translated = str_ireplace('PRICE', 'PRIX', $translated);
$translated = str_ireplace('QUANTITY', 'QUANTITÉ', $translated);
$translated = str_ireplace('TOTAL', 'TOTALE', $translated);
return $translated;

Be aware that errors might occur so backup your functions.php file before you try this one!

This concludes step 1 of the WooCommerce ghost strings translation. For the next step on the Checkout page there is the string “I’ve read and accept the terms & conditions” which was also in English. This is the string located in the file terms.php found in one of the following 2 locations:
– /wp-content/themes/YOUR-THEME-NAME/woocommerce/checkout/terms.php
– /wp-content/plugins/woocommerce/templates/checkout/terms.php

In my case the file terms.php was in the second location and the string I was looking for was in span HTML tag like this:
<span><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank" class="woocommerce-terms-and-conditions-link">terms & conditions</a>', 'woocommerce' ), esc_url( wc_get_page_permalink( 'terms' ) ) ); ?></span>

Edit accordingly your language translation and mind the special characters like apostrophe ’ and & sign & which can break your page coding.

Useful post regarding this topic can also be found on the official support page for WooCommerce plugin on WordPress.org website.


Leave a Reply

  1. meulemanpj · November 26, 2017

    You are a god!

    • janoshke · November 26, 2017

      Thanks, I’m glad you find this post useful.

  2. Mua Máy Rang Cà Phê Giá Tốt · November 26, 2017

    nice post guy! but some string not working!

    • janoshke · November 26, 2017

      Thanks. There has been a lot of changes and updates lately across the web. Please do share which ones don’t work so others may find this comment useful 😉

  3. jjspresss · November 26, 2017

    How do I add this for French and leave the english for EN?

    • janoshke · November 26, 2017

      This example shows French as default language which leaves some strings untranslated. However, if you need to have bilingual website then you should consider using a plug-in like Polylang, Loco or WPML.

  4. jpruf · November 26, 2017

    Worked like a charm!

  5. indrekomskyte · November 26, 2017

    Thank you so much!!!!!!! the code worked like a charm!!!!

    • janoshke · November 26, 2017

      You’re welcome. I’m glad it helped 🙂

  6. Zeeshan · November 26, 2017

    Hi janoshke
    I add your code top my site but it shows translated string in English language. I am translating ‘Availability’ from Eng(Native Language) to German. I just want to show translated string only when german language is activated.I am using polylang plugin.

    • janoshke · November 26, 2017

      Hi there,

      Please note that this translation of strings using the functions.php file (in my case) was for single language site. For multilanguage site you should be able to translate the strings via string translator in Polylang (works best in PRO version).


  7. Corrina Russo · November 26, 2017

    This rocks. Thanks you for sharing!

    • janoshke · November 26, 2017

      You’re welcome. I’m glad it helps 🙂

  8. esra · November 26

    This post is so helpful. A bunch of thanks

    • janoshke · November 26

      Thank you. I’m glad it helped you.