This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 0.17 hours from now. Thank you for your understanding.

This topic contains 1 reply, has 2 voices.

Last updated by Noman 6 months ago.

Assigned support staff: Noman.

Author Posts
April 18, 2019 at 12:53 pm #3639225

ireneF-7

Hi

I am not good at php, I have just taken the code online and use code-snippets to add a function to my website. The idea is to add an automatic badge once an item is out of stock. I would like to add two different labels, one in english and one in italian. This is the code:

//Add an out of stock overlay to product images when all variations are unavailable
add_action( 'woocommerce_before_shop_loop_item_title', function() {
global $product;
if ( !$product->is_in_stock() ) {
echo '<span class="sold-out-overlay">GONE</span>';
}
});

I would like to say "REGALATO" for the italian side.

Thanks for the help

April 18, 2019 at 1:21 pm #3639413

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting WPML Support.

I have wrapped the strings in the gettext functions __() with a text domain like 'themedomain’. Please use updated code:

//Add an out of stock overlay to product images when all variations are unavailable
add_action( 'woocommerce_before_shop_loop_item_title', function() {
global $product;
if ( !$product->is_in_stock() ) {
echo '<span class="sold-out-overlay">'.__('GONE','themedomain').'</span>';
}
});

- Please scan the theme from WPML >> Theme and plugins localization section.
- Then search strings from WPML >> String Translation and add it’s translation.

Please let me know if this resolves your issue or you need further assistance?

Thank you

The topic ‘[Closed] TRANSLATE PHP’ is closed to new replies.