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 11 replies, has 2 voices.

Last updated by Riffaz 1 month, 1 week ago.

Assigned support staff: Riffaz.

Author Posts
September 4, 2019 at 7:33 am #4508759

Innovationsraum

I am trying to:
Display the translated strings from the String Translation, but it doesn't show. But the normal page content is displayed correctly.

We have worked with WPML String Translation before, so this is a bit unexpected and I can't seem to find the problem. We followed the documentation and even read some forum threads, but so far, nothing has solved the problem.

Link to a page where the issue can be seen:
hidden link
(We have a htpassword in place. I can DM you the login data.)

I expected to see:
That when I switch languages, the translated strings will be shown.

Instead, I got:
The untranslated strings from the default language is shown.

September 4, 2019 at 8:48 am #4509341

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Pleas provide the details I requested.
The next reply is private.

Regards,

September 4, 2019 at 11:39 am #4510489

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Thank you for the details.

You are asking about these strings, right? hidden link
Where you are using these strings? only here hidden link ? or somewhere as well?
Let us know the URLs and screenshots where we can find these strings in use.

Regards,

September 4, 2019 at 11:57 am #4510593

Innovationsraum

Yes, these are the right strings. Everything with "Cookiebanner" is used in the place on the frontend you showed in your screenshot. You can find the theme files at the locations discribed in the private message. All the Cookiebanner strings are just used in the inc-cookiebanner.php file.

We have serval other strings – as you can see – and therefore places in the theme, where we use String Translation. Another example would be the strings in the Screenshot. These are strings for the 404.php and you can find them in this file. As with all the strings, they are not being displayed in the secondary language :/

September 5, 2019 at 10:31 am #4518445

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

icl_register_string( 'theme_mrht18', 'Newsletter: Shoutout Beschriftung Schaltfläche', 'Eintragen' );

That only registers the string for translation. you also have to translate it after
better using this : https://wpml.org/wpml-hook/wpml_register_single_string/

one registers the string (for example, when you save a new string in the backend), the other translates the string to display in the frontend

but it can be much easier than that.

you can simply use this in the frontend:

echo __( 'Eintragen' , 'theme_mrht18' );

when you view the string in the frontend it will be auto-registered

If you translate it, it should work
No filters or strange functions are needed in this method.
It's much easier.

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

So, please follow the format and update the code.
Then you will be able to fix this issue.

Let me know if you need anything else regarding this.

Regards,
Riffaz.

September 5, 2019 at 11:54 am #4518917

Innovationsraum

Is the method with

icl_register_string()

and

echo icl_t()

not supported anymore by WPML? I am confused, because it sounded like that from what you said.

If this method is not supported any longer, okay, that explains the issue, but we used this method to organize our string better. So we can have one file with all our theme strings and then refer to this file if we need strings in our templates.

It will be hard to explain the customer that he has to pay for us to change all the strings… so that's why I'm asking.

I hope you can understand my confusion and concern.

Cheers.

September 5, 2019 at 1:01 pm #4519415

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

It should work. what I am saying is that is just an old method.

Refer: https://wpml.org/wpml-hook/wpml_translate_single_string/

thats just the old method ... but it should still work

And, since version 3.2 we have new and better filters. that makes the work easier and need to use only once.

I am not sure whats going on here.
icl_register_string and icl_t should still be supported as far as I know.

If you are unable to move to the new method let me know, we have to check old method in a fresh and bug free environment again as it was tested very long time ago.'

Regards,

September 5, 2019 at 2:32 pm #4520167

Innovationsraum

Hi,

Alright, good to know.

I tried the method with

echo __( 'Eintragen' , 'theme_mrht18' );

in the inc-cookie-banner.php file. The String then showed up in the String translation, as expected. I translated the String. Then I went to the frontend and switched to secondary language. Unfortunately the string does not show in the translated language.

What have I done wrong?

September 6, 2019 at 4:46 am #4523313

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hurmm.. that is strange.

Might be a conflict or compatible issue then.

Could you please reproduce this issue in a bug free, fresh environment by following steps?

1. go to hidden link
2. configure the WPML as you have it on your site. at the last step (sitekey) just click next
3. add your code. you can get sftp and ssh details here: hidden link
4. set the page
5. translate it
6. recreate the issue.
7. let us know how to check this step by step

so, our developers will be able to check this and find the cause of this.
This process will take only 5 to 10 minutes as all are pre-configured already.

Regards,

September 6, 2019 at 6:05 am #4523413

Innovationsraum

Okay, I am not sure to what extend I should the website. Should I also install the Plugins we use? Or just the Theme?

September 6, 2019 at 8:46 am #4524125

Innovationsraum

Hi,

so I just was a bit frustrated and testet various things like deactivating plugins and trying out different settings for WPML… I just found what was wrong.

In the menu WPML > Theme and plugin localization there is an option for choosing the default language of a string. Our first language is German, secondary is English, so the strings from the theme are German. The option was checked, so WPML thought the strings default language is English. I unchecked it, now the translation shows.
Must have been an installation error or some developer accidently checked this option.

Cheers.

September 8, 2019 at 2:08 pm #4531791

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

That's not a default option. 🙂
So it was checked by someone accidentally.

Glad it works now.

Please close the ticket and open a new ticket if you have any other question.

Regards,
Riffaz.