Skip Navigation

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

Problem: Read More strings are not translated anymore

Solution: It is not a WPML issue. This problem is happening because of a wrong code in the functions.php file of their theme. Correcting it has fixed the issue.

Relevant Documentation: https://wpml.org/forums/topic/strings-are-not-translated-anymore/#post-13528831

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

Last updated by nascoL 1 year, 9 months ago.

Assisted by: Bigul.

Author Posts
April 4, 2023 at 2:07 pm #13401021

nascoL

I am trying to: see translated strings in our templates. They used to work, they are visible at String Translation, but the translations are not appearing.

Link to a page where the issue can be seen: hidden link. You see "Read more", but this needs to be Dutch "Lees meer"
This is with multiple strings across the website.

April 4, 2023 at 4:22 pm #13402499

Laura
Supporter

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hi,

thanks for contacting us.

Please try to
- delete one of the affected strings
- re-register it following one of the approaches suggested here https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/
- translate it again

If it doesn't work, please provide us with more information about what's creating the strings and where we can see them

April 11, 2023 at 2:01 pm #13446813

nascoL

HI,

Thanks for reaching out.

I tried the above, but to no avail.

It can be seen on the following page for example: hidden link

This string is used in multiple templates (I have attached a screenshot of the syntax used).

Also I provided a screenshot of the WPML string translation side.

Hopefully you can help debug this issue with me.

Screenshot 2023-04-11 at 15.59.43.png
Screenshot 2023-04-11 at 15.58.11.png
April 11, 2023 at 4:03 pm #13448043

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the updates. Hope these templates are part of your theme. Just to make sure, have you tried the following steps?

1) Visit *WPML>>Theme and plugins localization* page
2) Scroll down to *Strings in the themes* section
3) Choose your theme
4) Click on *Scan the theme for strings* and wait until the process complete
5) Visit WPML>>String Translation
6) Search for the *Read More* string and translate the string

Please visit WPML>>String Translation after a site backup and enable the *Look for strings while pages are rendered* option of *Auto register strings for translation* section(on the bottom of the screen). Then visit the frontend pages and check whether the issue is existing or not. This option will be disabled in a couple of hours automatically. But will help us to track the issue in similar cases.

--
Thanks!

Bigul

April 12, 2023 at 10:01 am #13454197

nascoL

Hi Bigul,

I have tried the suggestions, but they seem not to work.

See attached screenshot for a possible clue. The file that is shown at the View column of String Translation of the "Read more" translation, is only one reference file, but the string is present in at least 5 files.
Another clue might be a recent update, because it has worked before, but suddenly stopped working.

Thanks in advance, Dennis

Screenshot 2023-04-12 at 11.58.21.png
April 12, 2023 at 4:08 pm #13457633

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Dennis,

Thank you for the updates. Please fill in the private details fields(including the FTP details) after a full site backup{mandatroy}. I would like to access the admin area of your site for further checking. Refer to the following links for more details about our private information-sharing policies.

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

hidden link

Also, share with me the URL of the pages where this link is showing.

--
Thanks!

Bigul

April 19, 2023 at 2:30 pm #13505473

nascoL

PS. I won't give you all pages, because that are a lot, but a few to check:
hidden link
hidden link
hidden link
hidden link

Hope this will suffice!

April 19, 2023 at 4:08 pm #13506325

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Dennis,

Thank you for the login information and details. This requires more testing. So please allow me to make a duplicator copy of your site using the Duplicator plugin(https://wordpress.org/plugins/duplicator/) for debugging the issue on my local server. So we can troubleshoot the issue without affecting your live site.

--
Thanks!

Bigul

April 20, 2023 at 9:19 am #13510077

nascoL

Yes, please be my guest and try debugging it locally. Since yesterday there also has been a bug with translation of the websites (I opened a separate ticket for this), maybe related to the recent WPMl updates.

April 20, 2023 at 4:29 pm #13513257

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Dennis,

Thank you for the permission. I made a copy of the site and tested it locally. The issue is existing after the intial checks. So consulting with our team for the expert opinion. We will get back to you as early as possible. Please wait.

--
Thanks!

Bigul

April 21, 2023 at 9:11 am #13516515

nascoL

Thanks for your reply. I wil await your answer.

April 21, 2023 at 5:12 pm #13519333

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Dennis,

Thank you. The ticket is escalated to our second-tier team for further debugging. Because the bug is existing after the primary debugging procedures. We will get back to you as early as possible. Please wait.

--
Thanks!

Bigul

April 24, 2023 at 4:34 pm #13528831

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Dennis,

Our second-tier team has found the reason for this bug. It is because of the following code in the functions.php file of your theme.

function custom_text_replace($translated_text, $untranslated_text, $domain)
{
	switch ($untranslated_text) {
		case 'Get a Quote':
			$translated_text = __('Learn More', $domain);
			break;
		case 'Leave a Comment':
			$translated_text = __('Share Your Thoughts', $domain);
			break;
		case 'Search':
			$translated_text = __('Find', $domain);
			break;
		default:
			$translated_text = $untranslated_text;
			break;
	}
	return $translated_text;
}
add_filter('gettext', 'custom_text_replace', 20, 3);

We are getting the expected results on the local copy after commenting on this code. Please check the attached image.

This conflict happens because of the default condition. If strings don't match it will replace translated text with the original text therefore WPML translation doesn't work.

default:
	 $translated_text = $untranslated_text;
	 break;

So please correct this code and make sure you are getting the expected results or not.

--
Thanks!

Bigul

2023-04-24_21-53-29.png