Wordpress Polylang Custom String Translations

On some WooCommerce products I have “Sale” tags when a product is on sale. This is in the form of <span class="onsale">Sale!</span> generated by WooCommerce when you input a sale price.

I am using PolyLang for WooCommerce page and string translations, however the sale tag is not amongst the strings. I am trying to add this string translation into PolyLang so that it is recognized and then changed depending what the chosen page language is.

The sale tag also has the following CSS:

`text-transform: uppercase;`

In my child theme functions.php I have tried by adding these strings to see if any will change the string:

add_action('init', function() {
  pll_register_string('onsale', 'onsale');
  pll_register_string('onsale', 'Sale!');
  pll_register_string('onsale', 'SALE!');
});

Which works fine and adds the string translations into PolyLang, but the translations do nothing.

I have read that to add string translations it works like this:
pll_register_string('$NAME', '$STRING-TO-TRANSLATE');

Has anyone encountered this problem with sale tags? Or know how to fix?

Sponsor our Newsletter | Privacy Policy | Terms of Service