Skip Navigation

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

Problem:
The client is experiencing issues with pages in .php format not being translated on their website.
Solution:
If you're encountering issues with translating texts within PHP code, we recommend wrapping the strings in a gettext call. Afterward, scan the theme from WPML -> Theme and plugin localization and translate the strings using String Translation. We have provided documentation to guide you through the process of adding the gettext call to register the content in string translation:

If this solution does not apply to your situation, or if it seems outdated, please check our related known issues and verify the version of the permanent fix. Also, confirm that you have installed the latest versions of themes and plugins. Should you need further assistance, don't hesitate to open a new support ticket. We highly recommend visiting the WPML support forum for additional guidance.

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 3 replies, has 2 voices.

Last updated by Lauren 8 months, 1 week ago.

Assisted by: Lauren.

Author Posts
April 25, 2024 at 1:10 pm #15565840

bhavani-shankarS-2

Dear Lauren,

I hope this message finds you well.

I wanted to bring to your attention that while certain pages on our website, particularly those in WordPress visual text, are translating correctly, we have encountered an issue with pages in .php format not being translated.

Your assistance in resolving this matter would be greatly appreciated.

Thank you for your attention to this concern.

Please find the attachment for your reference

Warm Regards,
Ayush

April 25, 2024 at 1:13 pm #15565844

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-05:00)

Hi there, thanks for sharing the screenshots so I could understand the issue. In order to translate texts in PHP code, you will need to wrap the strings in a gettext call, then scan the theme from WPML -> Theme and plugin localization and translte the strings using String Translation. Here is documentation here to walk you through how to add the gettext call to get the content registered in string translation: https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

Please let me know if you need any further assistance and I will be happy to help.

April 26, 2024 at 5:53 pm #15571653

bhavani-shankarS-2

Dear Lauren,

I hope this message finds you well. I would like to kindly request your assistance with translating the attached .php page. Would you be able to lend your expertise to this task? Your help would be greatly appreciated.

Thank you for your attention to this matter.

Best regards,
Ayush

Screenshot 2024-04-26 at 11.22.56 PM.png
April 29, 2024 at 7:52 pm #15578650

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-05:00)

Here is another example of how to wrap your text in a gettext call so that it can be registered for translation.

<p>This is some sample text that needs translation.</p>
<p><?php _e('This is some sample text that needs translation.', 'your-text-domain'); ?></p>

Be sure to use a text domain, if your theme has an existing one you can use that. Once you have added the gettext calls like my example above, go to WPML -> Theme and plugin localization and rescan your theme for strings.