Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client added text that was not appearing for translation in WPML.
Solution:
First, we recommend wrapping the string with the gettext function to make it translatable. For example, use the following code:

_e('per person', 'woocommerce');

For more details, refer to our guide on adding gettext calls to PHP code.

Next, follow these steps to ensure the string appears in WPML's String Translation:
1. Go to String Translation.
2. Enable the "Auto-register strings" option.
3. Visit the page on the front end where the string is displayed.
4. Disable the "Auto-register strings" option.
5. Search for the string to translate it.
For detailed instructions, please visit our guide on finding strings that don't appear on the String Translation page.

If this solution does not resolve your issue or seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket.

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 11.35 hours from now. Thank you for your understanding.

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by Osama Mersal 1 month, 3 weeks ago.

Assisted by: Osama Mersal.

Author Posts
July 29, 2024 at 8:16 am #16014340

aeT

Background of the issue:
I added text to add "per person" after the price on my WooCommerce products. I used gettext and then looked in string translation and can't find the string to translate it to Russian, Portuguese, Spanish. Here is the code I used: add_filter('woocommerce_get_price_suffix', 'bbloomer_add_price_suffix', 99, 4); function bbloomer_add_price_suffix($html, $product, $price, $qty) { $html .= gettext(' per person'); return $html; }

Symptoms:
The string 'per person' is not appearing in the WPML string translation.

Questions:
Why is the string 'per person' not appearing in WPML string translation?
How can I make the string 'per person' available for translation in WPML?

July 29, 2024 at 9:36 am #16014908

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

Thanks for contacting WPML forums support. I'll be glad to help you today.

Please wrap the string with the get text function. Kindly check this guide.

For example:

_e('per person', 'woocommerce');

Best regards,
Osama

July 29, 2024 at 12:31 pm #16015932

aeT

Thank you for your advice

I changed the code and rescanned but still it does not appear in string translation.

Should I do something else?

Thank you in avance

July 29, 2024 at 12:35 pm #16015940

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

Please check the following steps:

1- Go to String Translation
2- Enable the "Auto-register strings" option
3- Visit the page on the front end where you can see this string
4- Disable the option
5- Search for the string to translate it

Kindly check this guide.

Best regards,
Osama

July 29, 2024 at 12:41 pm #16015995

aeT

In fact I have a problem with the gettext.

It is showing on the page as this:

Warning: gettext() expects exactly 1 parameter, 2 given in /home/tribalmy/gorgeousturkeytours.com/wp-content/themes/salient-child/functions.php on line 52

This is what I wrote:

function bbloomer_add_price_suffix( $html, $product, $price, $qty ){
$html .= gettext(' per person', 'woocommerce');
return $html;
}

July 29, 2024 at 12:45 pm #16016000

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

Please try the following code.

function bbloomer_add_price_suffix( $html, $product, $price, $qty ){
$html .= _e(' per person', 'woocommerce');
return $html;
}

Best regards,
Osama

July 29, 2024 at 12:48 pm #16016002

aeT

That puts "per person" in front of the price

per person90,00 €

Best regards

July 29, 2024 at 12:50 pm #16016006

aeT

But... it appears in string translation!

Can I have it after the price with a space?

Thank you in advance

July 29, 2024 at 1:16 pm #16016268

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

Please try the following.

function bbloomer_add_price_suffix( $html, $product, $price, $qty ){
$html .= __(' per person', 'woocommerce');
return $html;
}

Best regards,
Osama

July 29, 2024 at 1:27 pm #16016305

aeT

Thank you so much for your support - that worked perfectly

aeT confirmed that the issue was resolved on 2024-07-29 13:27:29.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.