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 thread is resolved. Here is a description of the problem and solution.

Problem:

Admin text that was added to string translation and translated doesn't show the translation on the front-end.

Solution:

This issue happened with a string in an incompatible plugin. Any other method of trying to make the string show didn't work. The only thing that worked, in this case, was this CSS hack.

1. In Settings -> Related Posts -> Output (tab), I changed the input strings like this.

<h3 class="change-title"><span>You may also find interesting:</span></h3>

And:

<span class="change-no-related"><span>No related posts were found.</span></span>

2. The in Appearance -> Customize -> Additional CSS, I've added the following CSS.

.change-title:lang(he) span{
    display: none;
}
 
.change-title:lang(he):after {
  content: 'אולי יעניין אתכם גם:';
}
 
.change-no-related:lang(he) span{
    display: none;
}
 
.change-no-related:lang(he):after {
  content: 'לא נמצאו פוסטים קשורים';
}

This special CSS directive only works for the Hebrew page. And what it does is switch the content of the HTML tag to Hebrew.

Please remember to not change the HTML tags and CSS classes in Settings -> Related Posts -> Output (tab). And not change the CSS directives in Appearance -> Customize -> Additional CSS.

The code here can be adjusted to any language. The language code that is in parentheses needs to be the language code that is on your site and which you want to have the CSS directive work for.

This topic contains 8 replies, has 2 voices.

Last updated by veraK 2 months ago.

Assigned support staff: Itamar.

Author Posts
August 7, 2019 at 11:57 am #4354657

veraK

This is in continuance to this ticket: https://wpml.org/forums/topic/the-plugin-string-translation-failed-to-load-properly/ - it has been in chat a few days ago.

I am trying to: I have a plugin called Contextual Related Posts. It adds "Related Posts" "widget" beneath a post. In previous ticket, the problem was that the Title of the widget was in admin text and I couldn't make it register. The support person, Amit, helped resolve that, via registering it through functions.php file.
Now, the string exists, it has been translated (from Hebrew to English), but it only appears in Hebrew on both Hebrew and English pages.

Link to a page where the issue can be seen: any post in English. Here, for example.
hidden link

I expected to see: "You may also find interesting"

Instead, I got: "אולי יעניין אתכם גם"

August 7, 2019 at 4:42 pm #4356933

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

Was it Shekhar or Amit who helped you resolve that, via registering it through functions.php file?
I'm asking this to know whether there is more information that I need to be exposed to rather than the information in the link that you gave here to the previous chat where Shekhar helped you.
https://wpml.org/forums/topic/the-plugin-string-translation-failed-to-load-properly/

This might not be working because a GetText call does not wrap the string in your files ("You may also find interesting") or wrapped in the wrong GetText call. More information about WordPress GetText call you can find in our documentation here.
https://wpml.org/documentation/support/achieving-wpml-compatibility-for-your-themes-and-plugins/#11
https://wpml.org/documentation/support/translating-the-theme-you-created/
https://wpml.org/faq/language-setup/

Please let me know if this information is helping you solve the problem.

Regards,
Itamar.

August 7, 2019 at 6:43 pm #4357507

veraK

Hi, Itamar,
Actually, it was you. About a week ago.
I couldn't recall the name except that it was one of ours, so I mistakenly wrote Amit. Sorry.
BTW, the reason I couldn't recall the name is because the chat kept changing the name of the supporter all along the chat, and then, at the end, in the email, printed the last name given all through the chat - that of Shekhar.

August 8, 2019 at 10:40 am #4361897

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, Vera.

OK, I've done some investigation, and now I understand the way things went. I helped you on this issue in this chat here.
https://wpml.org/forums/topic/cannot-add-admin-string-to-string-translation/
After registering the string, it did appear in String Translation for translation, but then you found out that the translation is not showing on the front-end. So you opened another chat and Shekhar helped you here.
https://wpml.org/forums/topic/the-plugin-string-translation-failed-to-load-properly/
In the last chat with Shekhar, you said that the issue is resolved and now the "אולי יעניין אתכם גם" string does get translated on the front-end to "You may also find interesting".
So is the problem returned now?

Regards,
Itamar.

August 8, 2019 at 10:52 am #4362033

veraK

Itamar,
Thank you for getting up to date. But that is not exactly how it went.
1. The first issue - with you - was registering the strings from admin texts. Though it was difficult even for you, you managed to do so by adding a line into the functions.php file.
2. The second ticket had been due to the function.php line not being deleted. It caused the String Translation plugin to not load properly, which sent the whole site into "Technical problems".
So, though related to the first ticket, it was a different issue.
3. Now, this issue is sort of next step not working again (it did for a moment, after registration, in the first issue - and doesn't now).
The strings are registered in String Translation. I can see them well.
They are translated correctly. It shows "translation complete".
But on the front end - at the bottom of both Hebrew and English posts it displays the Hebrew string. Not the translation to English on the English posts.
Is that more clear now?
Thank you,
Vera

August 10, 2019 at 7:07 pm #4375895

veraK

Itamar?

August 11, 2019 at 4:17 pm #4377123

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, Vera and sorry for the late reply here.

You wrote: "Now, this issue is sort of next step not working again (it did for a moment, after registration, in the first issue - and doesn't now)."
Did it also work (for a moment) on the front-end?

Also please let me know whether you have checked the what I've mentioned in my first reply on this thread?
I'm talking about if the string is wrapped in a Gettext function in the theme's file.

If you need further help with this, please share the access details to your site with me and let me know precisely on which file I can find the "אולי יעניין אתכם גם" string.

I'm enabling a private message for the next reply.

Privacy and Security Policy

We have strict policies regarding privacy and access to your information. Please see:
https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

**IMPORTANT**

- - Please make a backup of site files and database before providing us access. --

Thanks,
Itamar.

August 12, 2019 at 1:44 pm #4381365

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, Vera.

I've fixed this issue on your site. Please see the attached screenshots. The only possible way to do it was with CSS. Here is what I did.

1. In Settings -> Related Posts -> Output (tab), I changed the input strings like this.

<h3 class="change-title"><span>You may also find interesting:</span></h3>

And:

<span class="change-no-related"><span>No related posts were found.</span></span>

2. The in Appearance -> Customize -> Additional CSS, I've added the following CSS.

.change-title:lang(he) span{
	display: none;
}

.change-title:lang(he):after {
  content: 'אולי יעניין אתכם גם:';
}

.change-no-related:lang(he) span{
	display: none;
}

.change-no-related:lang(he):after {
  content: 'לא נמצאו פוסטים קשורים';
}

This special CSS directive only works for the Hebrew page. And what it does is switch the content of the HTML tag to Hebrew.

Please remember to not change the HTML tags and CSS classes in Settings -> Related Posts -> Output (tab). And not change the CSS directives in Appearance -> Customize -> Additional CSS.

Can you please confirm that this issue is closed now.

Thanks,
Itamar.

August 12, 2019 at 4:56 pm #4382509

veraK

My issue is resolved now. Thank you!