[SOLVED] How to translate WooCommerce term 'Products' to 'Properties'

Issue

For the term Product I’ve managed to change admin dash labels and WooCommerce post type labels such as 'edit_item'=> __('Edit Property',....

However, WooCommerce seems to have Products, the plural of product in a few different places. For example; Admin Dash -> WooCommerce -> Settings … Menu = (General, Products, Payments) etc.

So when I try to translate ‘Product to Property’ and ‘Products to Properties’, it seems to create the word Propertys

Would I be approaching this in the wrong way? Any advice please on where I’m going wrong?

Thanks,

enter image description here

add_filter('gettext', 'translate_text');
add_filter('ngettext', 'translate_text');
function translate_text($translated) {
$translated = str_ireplace('Product', 'Property', $translated);
$translated = str_ireplace('Products', 'Properties', $translated);
$translated = str_ireplace('Product Categories', 'Property Categories', $translated);
return $translated;
}

Solution

add_filter('gettext', 'translate_text');
add_filter('gettext_woocommerce', 'translate_text');
add_filter('ngettext', 'translate_text');

function translate_text($translated) {
    $translated = str_ireplace('Products', 'Properties', $translated);
    $translated = str_ireplace('Product', 'Property', $translated);
    $translated = str_ireplace('Product Categories', 'Property Categories', $translated);
    return $translated;
}

Answered By – mujuonly

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *