Skip Navigation

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

Problem:

I have to translate a string that I have added in my child theme functions.php

Solution:

Make sure you are following our documentation and:

- The text must be wrapped in gettext calls.
- There must be a textdomain argument.

Example:

_e( 'Thank you!', 'my-plugin-domain' );

- https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

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

This topic contains 8 replies, has 2 voices.

Last updated by massimoS-6 1 year, 12 months ago.

Assisted by: Dražen Duvnjak.

Author Posts
May 1, 2022 at 6:18 am #11127845

massimoS-6

Tell us what you are trying to do?
I have translate a string that I have added in my child theme functions.php

Is there a similar example that we can see?

What is the link to your site?
hidden link original string
hidden link not correct string

I have found the string using string translation, that was not a problem, I have translated and saved the string form Italian to Germana and English, but when I check, it's always in Italian.

Thank you!
Max

May 2, 2022 at 9:26 am #11131671

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello Max,

please make sure you are following our documentation and:

- The text must be wrapped in gettext calls.
- There must be a textdomain argument.

- https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

Please check if the issue happens when only WPML plugins are enabled, maybe some other plugin is causing the issue or the cached page is showing.

Let me know how it goes.

Thanks,
Drazen

May 2, 2022 at 10:22 am #11132137

massimoS-6

Hi Drazen, thank you!

My php function is:

$domain = 'enfold';
function wnd_checkout_code( ) {
echo __("<b>ATTENZIONE:</b> per validare ordine sarà necessario caricare una immagine fronte/retro di un proprio documento identità in corso di validità (es. Passaporto, Carta d'Identità,...). Se non poteste farlo ora, <b>avrete 3 giorni di tempo</b> dal momento ordine per inviare il documento<br>Utilizzando Google Pay, dovrete per forza inviare i documenti per email in un secondo momento.<br><br>",$domain);
}

I have used as domain the parent theme as I am using a child theme.
I have disabled the caching plugin, then WPML then checked from another browser.
Result is the same. No translation is showed even if everything has been translated.

Screenshot 2022-05-02 at 12.21.19.png
May 2, 2022 at 11:04 am #11132545

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

thanks for getting back.

Please use the suggested approach from our documentation shared, in your example, since you want to echo you can use the next example:

_e( 'Thank you!', 'my-plugin-domain' );

Also please try using only text without HTML Tags, as HTML should be part of the code not the string text for translation.

Let me know how it goes.

Thanks,
Drazen

May 2, 2022 at 11:25 am #11132761

massimoS-6

Done everything, same result. I do not have the html formatting but still the text does not change switching language.

May 2, 2022 at 11:33 am #11132797

massimoS-6

Hi again,

I have noticed one strange behaviour when I deactivate WPML: if I go to this page
hidden link I see three gun belt products now (one per language)
If I click on the first or second (german or italian) the single product has both german and italian text. If I click on the third (english) it contains only the english text.

May 2, 2022 at 11:43 am #11132823

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

please note we limit 1 issue per 1 ticket to keep things clear and easy to follow.

I am afraid I am not sure what happens when WPML is disabled in your case or what issue happens, but if you need further help when disabling WPML and have some doubts, please open a new separate ticket or let me know and I can do it for you, we will be glad to further help.

As for issues with string translations:

1) Please share the URL and steps where I can see the text on frontend

2) In order to investigate this issue and to understand it better, I would need to access your website.

Please make a full backup of your site (files and database) and confirm it in your next reply. I might need to enable/disable plugins, switch themes and access your website database.

I would need to access both your site's wp-admin and FTP account. Be sure to provide both.

I have enabled the private username and password fields in your next reply.

You can safely add your information into these fields.

Thanks,
Drazen

May 2, 2022 at 1:44 pm #11133729

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

thanks for getting back.

I changed the code to correspond to the example I shared, then I scanned the child theme for strings via WPML > Theme and plugin localization. Then translated from WPML > String Translation.

It works and shows fine, translated. Image attached.

Please check.

Thanks,
Drazen

Screenshot_1.jpg
May 2, 2022 at 2:26 pm #11134077

massimoS-6

I don't know why it did not work when I tried, I thought I changed the code correctly, but I can see that the domain is now different. Thank you!

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