Skip Navigation

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

Problem:
You are trying to translate custom strings in your child theme using WPML, but the translation for 'How It Works' is not appearing on the front end, despite using the

icl_register_string

function and adding translations in the WPML String Translation section.
Solution:
The issue arises because the

gettext

function is not correctly implemented; it lacks a text-domain. You should modify your code to include the text-domain, like this:

__('How It Works', 'my-theme-domain');

Additionally, instead of using

icl_register_string

, we recommend using the

wpml_register_single_string

action and then retrieve the string translation with

wpml_translate_single_string

. For detailed guidance on using gettext, visit How to Use Gettext, and for more on registering strings, see WPML register single string.

If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, please open a new support ticket. We also 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. For further assistance, you can contact us directly through our support forum.

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 1 reply, has 0 voices.

Last updated by Andrey 2 months, 2 weeks ago.

Assisted by: Andrey.

Author Posts
February 28, 2025 at 7:52 pm #16762610

bradleyC-3

Background of the issue:
I am trying to translate custom strings added in our child theme files using WPML. We registered the strings with the icl_register_string function and added translations in the WPML String Translation section. The translation for 'Menu' works, but 'How It Works' does not appear. Link to a page where the issue can be seen: hidden link <?php _e('Menu'); ?> <?php _e('How It Works'); ?> icl_register_string('look-child-html', 'Header Menu Menu', 'Menu'); icl_register_string('look-child-html', 'Header Menu How It Works', 'How It Works');

Symptoms:
The translation for 'How It Works' is not appearing on the front end.

Questions:
Why is the translation for 'How It Works' not appearing on the front end?

February 28, 2025 at 9:01 pm #16762771

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

While one of my teammates addresses your ticket, I will provide you with some initial debugging steps.

It appears that you are not using the gettext function correctly; it is missing a text-domain. It should look like this:

__('How It Works', 'my-theme-domain');

How to Use Gettext:
https://wpml.org/documentation/support/how-to-use-gettext/

If you plan to use the `icl_register_string` function, you should use the `wpml_register_single_string` action instead and then use `wpml_translate_single_string` to retrieve the string translation.

For more information, you can visit https://wpml.org/wpml-hook/wpml_register_single_string/.