Skip Navigation

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

Problem:
The client modified the English part of a string in their custom theme's PHP file and updated the translation in WPML, but the Polish tag archive pages still displayed the untranslated string 'Sorted articles by'.
Solution:
1. Ensure that all WPML plugins are updated to the latest versions and check if the issue persists when all other plugins are disabled, using only WPML plugins.
2. Test the translation of the modified string on different pages and with the default WordPress theme, such as 2021, to see if the issue is specific to the custom theme.
3. Replace the variable in the gettext function with a literal string for the text domain in the PHP file:

'tag_archives' => __('Sorted articles by', 'cherry'),

4. Rescan the theme for strings in WPML under 'Theme and plugins localization' and then translate the strings again in 'String Translation'.
For more details on enabling text translation for themes not compatible with WPML, visit https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/.
If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, please open a new support ticket. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. For further assistance, you can also visit our support forum at https://wpml.org/forums/forum/english-support/.

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.

Our next available supporter will start replying to tickets in about 0.81 hours from now. Thank you for your understanding.

This topic contains 7 replies, has 3 voices.

Last updated by Long Nguyen 1 month ago.

Assisted by: Long Nguyen.

Author Posts
October 6, 2024 at 10:03 pm #16258544

Sergio

Background of the issue:
I have tag archive pages on my site, such as hidden link. The title 'Tag archives' was translated correctly before. I modified the English part in the file /includes/locals.php from 'tag_archives' => __('Tag Archives', $domain), to 'tag_archives' => __('Sorted articles by', $domain). I then rescanned the theme for new strings and translated 'Sorted articles by' in the 'String translation' section.

Symptoms:
The Polish tag archive pages still show the untranslated string 'Sorted articles by'.

Questions:
Why is the Polish tag archive page still showing the untranslated string?
How can I ensure the translation for 'Sorted articles by' is applied correctly?

October 8, 2024 at 12:22 pm #16265340

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

Thanks for contacting us.

While you wait for my colleague to take over the ticket, let me try to help you with the issue quickly.

1) Please make sure to update WPML plugins to the latest versions, and check if the issue still happens when all other plugins are disabled while using only WPML plugins.

2) I see you are using a custom theme, so this could be difficult to debug for us from WPML support. Can you try to test if the translation of your string works fine on some other page and on that archive if you use example from our guide:

__( 'Thank you!', 'my-plugin-domain' );

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

3) Check if translations of these example strings work fine with the WP default theme, like 2021.

Let us know how it goes.

Regards,
Drazen

October 8, 2024 at 2:54 pm #16266099

Sergio

1) Plugins updated
2) yes, gettext are working fine. It's a huge site and it's already translated more than 90%. Both normal strings and gettext work fine. Only in this specific case somehting is not working. But BEFORE chaning the ` 'tag_archives' => __('Sorted articles by', $domain)` line the string translation was working here. I just wanted to have the English version differ than what was in PHP.
3) Yes, they work fine in this custom theme and in default wp theme. Only this specific string is not working.

October 8, 2024 at 6:26 pm #16267153

Sergio

Update. I just noticed that aftert my change in that php file, also other words that are there in that php file stopped to be translated properly.

The same issue happens now here: hidden link
This is a category page.

Please kindly help

October 14, 2024 at 1:30 am #16283754

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Sergio,

I would like to request temporary access (wp-admin and FTP) to your site so I can take a better look at the issue. It would be better to have a testing site where the issue is replicated. Your next reply is set to private to share the info.

❌ IMPORTANT: Please backup your database and website before proceeding ❌
You can use this plugin to create the backup: https://wordpress.org/plugins/duplicator/
✙ I would need your permission to de-activate and re-activate Plugins and the Theme to change configurations on the site if needed. This is also a reason the backup is critical.

Looking forward to your reply.
Thanks

October 16, 2024 at 2:08 am #16292903

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I got the issue. You need to use a real string instead of a variable for the text domain:

'tag_archives' => __('Sorted articles by', 'cherry'),

It is noted in the WordPress documentation https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#basic-strings

Do not use variable names or constants for the text domain portion of a gettext function. For example: Do not do this as a shortcut:

__( 'Translate me.' , $text_domain );

then go to WPML > Theme and plugins localization > Scan strings in the theme and go back to String Translation to translate strings.

Looking forward to your reply.
Thanks

String Translation ‹ Anahata Tantra Temple — WordPress 2024-10-16 09-07-36.jpg
Artykuły: abstynencja seksualna | Świątynia Anahata Tantra 2024-10-16 09-07-17.png
October 16, 2024 at 8:00 pm #16297706

Sergio

Thank you, however how is it possible?

I am using this theme since almost 10 years. And they were being translated well. And still the rest of strings with $domain) are being translated well. Only this one stopped working and needs to be writtem as 'tag_archives' => __('Sorted articles by', 'cherry'),

October 17, 2024 at 1:33 am #16298055

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I'm not sure when exactly the change/update was released and affected your theme but you can see in the WordPress documentation, you should use a literal string for the text domain. For other strings, I think it is generated for the .mo file and has worked in the past. But now, if you change another string in the file locals.php and re-scan the theme, it doesn't work as the string "Sorted articles by".

Generally, please use a literal string for the text domain to allow WPML to scan and translate strings in your files correctly.

Thanks.

October 22, 2024 at 7:37 pm #16319193

Sergio

Thank you very much. It makes sense.