Skip Navigation

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.

Assisted by: Sumit.

Author Posts
February 4, 2022 at 1:34 pm #10509135

emelieC

Hello I have used the following codes to make some customisations to Woocommerce to fit our business.

But I now find that None of the strings I have changed are translatable. Could you please help me out?

Here are the lines that I have used to change some strings in this pastebin containing:

// Change WooCommerce "Related products" text - BUT MAKES THIS UNTRANSLATEABLE: Similar hotel deals

/**
* Rename product data tabs - BUT MAKES THIS UNTRANSLATEABLE: Booking information
*/

// Change default sorting in Woocommerce to A to Z - BUT MAKES THIS UNTRANSLATEABLE: Sort from A to Z

Please check the code from functions.php here:

https://pastebin.com/WNjaeQXg

Thanks and hope you can help! 🙂

February 4, 2022 at 2:01 pm #10509427

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thank you for contacting the support forum.
Before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.

I checked the code, using gettext filter for changing the text is very expensive.
You should avoid it and look for a filter to change the text, if not available ask the plugin developer to add a filter or provide a way to change the text.

Anyway, for the solution, you should not pass variable in text domain

$translated = esc_html__('Similar hotel deals', $domain);

Instead use text value.

Please check the updated code

$translated = esc_html__('Similar hotel deals', 'your-theme-domain');
$tabs['additional_information']['title'] = __( 'Booking information', 'your-theme-domain' );     // Rename the additional information tab
$options[ 'menu_order' ] = __('Sort from A to Z', 'your-theme-domain'); // rename

Where "your-theme-domain" should be replaced by the actual theme domain. Generally, it is the name of the theme folder e.g. "twentytwentyone" for Twenty Twenty One theme.

Then please follow these steps:-
1. Go under "WPML -> Theme and plugins localization"
2. Scroll down to "Strings in the theme" and select the active theme then click on "Scan the theme for strings"
3. Once you followed the above steps go under "WPML -> String Translation". All strings available for translation should display in the table you see there.
Do you see them? If yes, all you need to do is click on "translations" next to each string you want to translate.

Hope it helps.

Thanks

February 10, 2022 at 5:02 pm #10554065

emelieC

Hello!

That iis what I call great support!

Could you please look into this last one I have added as well?

I tried to figure it out but it doesnt look like the others I believe:

https://pastebin.com/Bhf9kQ84

Thanks again!

February 11, 2022 at 3:00 pm #10562077

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thanks for the feedback!

For this string, you can concatenate the strings like

$price = '<span class="woocommerce-Price-amount amount">'. __('Special Price Conditions', 'your-theme-domain') .'</span>';

Please have a look at
1. hidden link
2. https://developer.wordpress.org/reference/functions/__/

Thanks

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.