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.

This topic contains 6 replies, has 2 voices.

Last updated by Yulia Krzeminska 1 year, 10 months ago.

Assisted by: Shane.

Author Posts
June 17, 2022 at 11:39 am #11484871

Yulia Krzeminska

Hi!

Could you tell me how I can create custom string for translation and use it in php theme files ?

Thank you.

June 17, 2022 at 3:30 pm #11486471

Shane
Supporter

Languages: English (English )

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

Hi Yulia,

Thank you for getting in touch.

Generally to make a string translatable with WPML you will need to wrap that string in a gettext function where you've defined the text domain and the text.

Example

_e('my-string','text-domain');

For further clarification you can see the documentation on this below.
https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/
Thanks,
Shane

June 17, 2022 at 3:34 pm #11486497

Yulia Krzeminska

Hi!
Thank for your feedback. If I use "_e('my-string','text-domain')" so string "my-string" automatic will created in "String translation", correct?

June 17, 2022 at 6:07 pm #11486865

Shane
Supporter

Languages: English (English )

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

Hi Yulia,

That's correct. The string will show up in our string translations plugin, ready to be translated.

Thanks,
Shane

June 17, 2022 at 6:33 pm #11486995

Yulia Krzeminska

Hi, Shane!

I added string, but it was not created in "string translation".

filter.JPG
code.JPG
June 17, 2022 at 6:47 pm #11487145

Shane
Supporter

Languages: English (English )

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

Hi Yulia,

Once you've added the string, then you will need to rescan the theme.

Follow the instructions below and rescan your theme and let me know if the string shows up then.
https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/#scanning-for-hard-coded-strings

Thanks,
Shane

June 17, 2022 at 7:07 pm #11487197

Yulia Krzeminska

Yes, it's works. My issue is resolved now. Thank you very much!

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