Skip Navigation

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

Problem:
The client needed help with translating strings in PHP code that were not properly wrapped for translation.
Solution:
First, we guided the client to wrap all texts in gettext calls as per our documentation. Specifically, we advised checking step number 2.

Next, we replaced the client's original PHP code:

<p class="you_save_text_woocommerce"></p><p style="font-size:small;color:#b16315">Te Ahorras: <b> <?php echo wp_kses_post( wc_price( $amount_saved ) ) ; ?></b></p>

with:

<p class="you_save_text_woocommerce" style="font-size:small;color:#b16315"><?php _e( 'Te Ahorras:', 'wpml-fix' ); ?> <b><?php echo wp_kses_post( wc_price( $amount_saved ) ); ?></b></p>

After modifying the code, we instructed the client to use the String Translation feature in WPML to translate the modified string. The steps included enabling the "Look for strings while pages are rendered" option, visiting the front end to render the string, and then searching for the string in the String Translation interface.

If this solution does not apply to your case, or if it 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 issues persist, 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.

Tagged: 

This topic contains 4 replies, has 0 voices.

Last updated by Osama Mersal 1 week ago.

Assisted by: Osama Mersal.

Author Posts
February 1, 2025 at 9:25 pm #16659248

jing-yingM

Background of the issue:
I found the strings in the PHP code in the "WPCode Lite" plugin, but the strings translation can't show in the front end. I am trying to translate the PHP code in the "WPCode Lite" Plugin for my site hidden link.

Symptoms:
The translated strings in the PHP code do not appear on the front end.

Questions:
How can I make the translated strings appear on the front end?

February 2, 2025 at 12:25 pm #16659887

Osama Mersal
Supporter

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

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

Hi,

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

You need to wrap the test in the GetText function. After that, you can translate the string using the string translation. Kindly check this guide to know more about translating hard-coded strings.

Best regards,
Osama

February 6, 2025 at 8:02 pm #16677047

jing-yingM

Hello

How to wrap the test in the GetText function?
I can't find the guide for wrapping the test in the GetText function.

Thank you

February 7, 2025 at 11:38 am #16679401

Osama Mersal
Supporter

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

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

Hi,

Here is the hidden link">guide. Please check step number 2 (Wrap All Texts in GetText Calls).

Best regards,
Osama

February 8, 2025 at 6:57 pm #16683051

jing-yingM

Hi

I can't understand the step number 2 , Could you provide the code wrapped and I can update the code in code snippets . I checked with the resolution from here(https://wpml.org/forums/topic/translate-the-strings-in-custom-code-snippet-in-codesnippets-plugin) ,But I can't understand the code.

Thank you

February 9, 2025 at 8:52 am #16683600

Osama Mersal
Supporter

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

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

Hi,

I would need to look closely at your site, so I would need to request temporary access (WP-Admin and FTP)
Preferably to a test site where the problem has been replicated.

Your answer will be private, meaning only you and I can access it.

❌ Please backup your database and website ❌

✙ I need your permission to deactivate and reactivate the plugins and themes and change site configurations. This is also why the backup is critical.

✙ I also need your permission to take a local copy of your site to debug the issue without affecting your live site.

Best regards,
Osama

February 11, 2025 at 9:36 am #16690624

Osama Mersal
Supporter

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

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

Hi,

Thanks for the access details. I replaced your code:

<p class="you_save_text_woocommerce">
<p style="font-size:small;color:#b16315">Te Ahorras: <b> <?php echo wp_kses_post( wc_price( $amount_saved ) ) ; ?></b>
</p>

With

<p class="you_save_text_woocommerce" style="font-size:small;color:#b16315">
    <?php _e( 'Te Ahorras:', 'wpml-fix' ); ?> 
    <b><?php echo wp_kses_post( wc_price( $amount_saved ) ); ?></b>
</p>

After that, I translated the string via hidden link">String Translation. Please check if the string on the front end is translated correctly.

Best regards,
Osama

February 13, 2025 at 11:43 am #16701511

jing-yingM

Hi

Thanks for your response.
I changed the code with the new one and I tried to use string translation to translate.
However , I noticed that in the live site the domain "wpml-fix" can' t display. So I can't finish the translation . Could you help me look into this issue in the live stie?

How can I add the "wpml-fix"domain?

Staging site.png
Live site.png
February 13, 2025 at 12:04 pm #16701775

Osama Mersal
Supporter

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

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

Hi,

After changing the code, please try the following steps:

1- Go to WPML-> String Translation
2- Enable the "Look for strings while pages are rendered" option
3- Visit the front end, where you can see the string
4- Go back to String Translation
5- Search for the string

Best regards,
Osama