Skip to content Skip to sidebar

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Los_Angeles (GMT-07:00)

Tagged: 

This topic contains 10 replies, has 0 voices.

Last updated by Bobby 1 week ago.

Assisted by: Bobby.

Author Posts
August 14, 2025 at 4:20 pm #17321607

paulaS-9

Background of the issue:
I'm trying to get the String Translation plugin to detect all 'in-code' strings in our theme. The site is built using the Timber framework, which uses Twig for template files. The theme has been scanned for strings manually, but only strings in PHP files were picked up initially. The 'Auto register untranslated strings' option is enabled.

Symptoms:
With the 'auto register' function enabled and pages being visited by me (logged in), no new strings were detected, until mysteriously after 6+ hours had passed, some of the 'Twig' strings showed up in the string translation list, but there were still some missing. There is no clear cause for this. I had been clearing caches and refreshing constantly, which did not result in any new strings being detected.

Questions:
Why are some strings in Twig templates not being detected immediately, if at all?
What could cause a delay in detecting strings in Twig templates?

August 14, 2025 at 7:03 pm #17322063

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

Please share with me a string from a twig template that is not being registered.

It would help us to review it in the code as that will allow us to see if they are properly registered using a gettext call.

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

Also, please note that Twig Templates are no longer officially supported by WPML
https://wpml.org/changelog/2025/05/wpml-4-8-will-drop-support-for-twig-templates/

August 15, 2025 at 2:39 pm #17323911

paulaS-9

Hi Bobby,

Here's one in particular I've been watching out for that still isn't showing up in WPML:

{{ __("Back to Library", "my-theme") }}

All other translatable stings in the theme are using the "double underscore" function as well.

August 16, 2025 at 7:41 am #17324626

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

I would like to request temporary access (wp-admin and FTP) to your site to test the issue.
(preferably to a test site where the problem has been replicated if possible)

**Before we proceed It is necessary to take FULL BACKUP of your database and your website. Providing us with access, you agree that a backup has been taken **

I often use the Duplicator plugin for this purpose: http://wordpress.org/plugins/duplicator/
You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you enter is private which means only you and I have access to it.

NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin.

Thank you,
Bobby

August 19, 2025 at 6:45 pm #17332553

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for the access details!

I was able to test this using the following:

1. Went to hidden link

2. Added a translation to Spanish (duplicated)

3. Went to WPML->String Translation-> found Back to Library and translated it.

It shows OK now when I visit hidden link

Can you please verify, and let me know your results.

Screenshot 2025-08-19 at 11.42.40 AM.png
August 19, 2025 at 8:22 pm #17332741

paulaS-9

Hi Bobby,

Thanks for the rundown. I do see "Back to Library" in the list of translatable strings now.

Can you elaborate a bit more on step 2? I'm still unclear how I would be able to repeat this and what the root cause of the problem is.

August 20, 2025 at 8:26 pm #17335550

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

Of course! I was able to locate the string by going to WPML->Theme and plugins localization -> select the theme and any plugins that might have strings that are missing and re scan them.

These were the steps I followed to resolve this.

Also, added the missing translation for the page/post.

August 26, 2025 at 9:34 pm #17349748

paulaS-9

I've followed the "Theme and plugins localization" steps and I'm only getting one new string added. I'm still unclear as to what you mean by "added the missing translation for the page/post". Can you please clarify?

We are also experiencing an issue where none of our translated strings are showing on the front-end, even in PHP files. For example, there is a button that says "Register" on the English side of the site, and it still says "Register" on the Spanish side of the site. It has been translated into Spanish as "Registrarse" through the String Translation function. I've synced the batch of strings already. Is there a step I'm missing in order to apply these translated strings on the front-end?

August 27, 2025 at 9:07 pm #17352993

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

When I reviewed your translation work the trnslation for the specific page was actually missing and not 100% finished, I had to finalize it and publish it.

I've followed the "Theme and plugins localization" steps and I'm only getting one new string added.
---> which string are you missing or is there a specific page that we can review?

For the second issue please share a URL where we can view this in the front end.

August 29, 2025 at 12:43 am #17356478

paulaS-9

Hi Bobby, it seems to me that the two problems may be related. Can you clarify the EXACT steps you took when you say "added the missing translation for the page/post", and "...missing and not 100% finished, I had to finalize it and publish it"? You have been re-wording but not elaborating, so a detailed rundown (screenshots if possible) would help me understand what exactly you mean.

It feels like some of the nuances of our website are being overlooked here. Some "pages" on our site are WP archives which pull their content from other WP posts, which do not have permalinks or front-facing URLs. Think of them as CMS variables. It's built this way so we can send them directly through WPML to our translation provider.

For example, the "/library/" page is an archive. In the template files, I'm pulling in content form a private custom post type. Same with the footer content.

As for the problem string on my end, it's still "Back to Library" but if I can get an understanding of your method, I might be able to trigger the registration on my end.

I understand I'm ignoring your request for "...the second issue please share a URL..." but I am tight on resources and it takes significant time to create an environment with the exact conditions necessary to replicate an issue, considering we're already working with multiple environments. I believe if we can solve the root cause reliably, the second issue will be resolved. If that's not the case, I will set up another environment.

August 29, 2025 at 7:15 am #17356869

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for providing the above information.

I would like to clarify..the reason there is not an elaborate explanation is because my steps were quite simple. There is no special step that was taken.
https://wpml.org/forums/topic/automatic-string-detection-in-twig-templates-is-inconsistent/#post-17332553

I access the page in question->clicked on the translation, made sure it gets to 100% and published it.

Once that was done I went to WPML->Theme and plugins localization -> select the theme and any plugins that might have strings that are missing and re scan them.

If you would like, I still have access, please provide me with a page/post we can still reproduce this issue and I will gladly screen record the above steps.