Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 -

Supporter timezone: Europe/Zagreb (GMT+02:00)

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by Dražen 1 year, 3 months ago.

Assisted by: Dražen.

Author Posts
December 11, 2023 at 9:54 pm #15041091

bretislavS

Hello,

- I have a website with the latest version of WordPress.
- A custom theme used there which contains TWIG files.
- I am localizing the website using latest version of WPML.

My procedure to localize the TWIG content is as follows:
1. I have converted all strings in TWIG files into constants, such as:
title: __('Bezpečné transakční zprávy', 'twigcon'),
desc: __('Posílejte zabezpečené transakční e‑maily, zprávy SMS, PUSH oznámení, nebo třeba dopisy.', 'twigcon')|raw,
etc.

2. To show the strings in WPML, I go to WPML/String Translation and enable the "Look for strings while pages are rendered" option.
3. I render the pages, go back to the settings and export the discovered strings to a .po file.
4. I translate the .po file and import it back with new translations. The translations are successfully visible in WPML under the correct domain (twigcon in my case).

The problem:
When I load the website, some strings on the page appear translated and some remain in the original language. I have noticed that the problem is with strings that contain HTML entities.

When a constant in TWIG file contains a HTML entity, such as non-breaking hyphen (‑), non-breaking space, etc. WPML does not display its translation on the website, even though it exists in WPML database.

I have tried applying raw or escape_html filters to constants in TWIG files, but the results were the same. Nevertheless, if I delete the problematic string, rescan the website, and add the translation for that string manually from within WPML, it shows on the website correctly.

Can you please advise on how to make this work without any workarounds? I.e., export/import.

Can you also confirm that this is the correct procedure to localize the strings from the TWIG files?

What is the link to your site?
hidden link
(currently under a password, which I would prefer to not share publicly in a forum)

December 14, 2023 at 8:16 am #15061091

Dražen
Supporter

Languages: English (English )

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

Hello,

before we continue can you please check few things.

Please check if the issue happens when you are using WP default theme, and add 1 example string.

Disable all other plugins and leave only WPML plugins.

I would like to confirm issue is not caused by any other custom code or plugin.

Thanks,
Drazen

December 19, 2023 at 8:04 am #15089327

Dražen
Supporter

Languages: English (English )

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

Hello BS,

thanks for getting back.

Can you please check if your website is still active, I can not access the shared URL.

Also please share the page URL and string example where I can see the issue.

Thanks,
Drazen

December 19, 2023 at 11:29 am #15091723

bretislavS

Hello Drazen,

my apologies, the SSL was not working properly, please try again now.

There are only three TWIG strings and they are on the following page:

hidden link

These strings (constants) are available in the theme within index.twig under "twigcon" domain and they were correctly recognized by WPML when I enabled "Look for strings while pages are rendered".

You can see the excerpt of these constants from the index.twig here:
hidden link

I then exported the strings under this domain (twigcon) as .po file, added translations, and imported it back. See the exported .po file with translations here, if needed:
hidden link

Each translation starts with "Sample translation:" prefix to easily recognize whether the text has been switched or not.

Now, when you switch the language on the site to Slovak, you can see that the first string switches fine (this string does not contain any html entities), but the other two strings remain in original Czech language, likely because of the html entities used in them.

BS

December 19, 2023 at 12:12 pm #15092127

Dražen
Supporter

Languages: English (English )

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

Hello,

thanks.

I have checked and I can see the same issue is already reported to us and escalated to developers.

For now, you can use the workaround you mentioned first or try next:

- https://wpml.org/forums/topic/strings-only-work-with-look-for-strings-while-pages-are-rendered-enabled/#post-14747071

I will add this ticket to the dev ticket tracker and update you when there is news on version with the permanent fix released.

Regards,
Drazen

February 22, 2024 at 11:58 am #15333269

bretislavS

Hello,

since there has not been any update since December, 2023 and the issue still persists, can you please let me know if there is a plan to resolve this anytime soon? Unfortunately, manually updating individual strings is not a workaround we could employ.

Thank you for letting me know.
Best regards,
BS

February 22, 2024 at 1:26 pm #15333758

Dražen
Supporter

Languages: English (English )

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

Hello,

I am afraid this will take some time before we have a version with a permanent fix, currently, the fix is scheduled for WPML 4.7.

The best I can do i update you when the fix is released, and hopefully it will be sometime soon.

Hope you understand.

Regards,
Drazen