Skip Navigation

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

Problem:
The client is experiencing an issue where strings are only translated when the auto-register strings for translation feature is enabled. They have followed certain documentation and provided code examples from their site.

Solution:
1. We recommend generating .mo files by navigating to WPML > Support > Troubleshooting and clicking on "Show custom MO Files Pre-generation dialog box". It's crucial to back up the database and website before proceeding.

2. If the issue persists, we suggest replacing the custom function

translateTheme()

with the gettext function

__()

for outputting the button text. For example:

<?php echo __('Buy Now', 'dt_theme'); ?>

Afterward, scan for strings in the child theme by going to WPML > Theme and plugins localization and translate them.

For more information, please refer to our documentation on enabling text translation for themes not compatible with WPML.

If these steps do not resolve the issue, we recommend contacting one of our certified partners for further assistance. You can find a list of our certified partners here: https://wpml.org/contractors/.

If this solution doesn't look relevant, please open a new support ticket in our support forum.

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

Last updated by maraM-4 1 year, 5 months ago.

Assisted by: Long Nguyen.

Author Posts
January 3, 2024 at 3:41 am #15145075

maraM-4

Tell us what you are trying to do?
Strings are translated only when auto-register strings for translation is on

Is there any documentation that you are following?
I followed this:
https://wpml.org/errata/string-translations-are-not-visible-on-the-site-after-a-string-has-been-translated/
https://wpml.org/forums/topic/strings-are-translated-only-when-auto-register-strings-for-translation-is-on/

Is there a similar example that we can see?

What is the link to your site?
hidden link

wpml2.png
wpml1.png
January 3, 2024 at 4:18 am #15145142

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

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

Hi Mara,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

It looks like the translation string is not generated to the .mo file correctly. Please try to go to WPML > Support > Troubleshooting > Click on "Show custom MO Files Pre-generation dialog box" and generate .mo files to see if it helps.
❌ IMPORTANT: Please backup your database and website before proceeding ❌

I also see the string is located in the child theme, please share the code that you output the string in the frontend if it does not help.

Look forward to your reply.
Thanks

January 3, 2024 at 6:16 am #15145241

maraM-4

Hi Long,

I did. But it still didn't work. Are there any other solutions? Thank in advance

January 3, 2024 at 6:33 am #15145250

maraM-4

My code is:
<?php if (defined('IS_FL_CA_SITE') && IS_FL_CA_SITE == TRUE ) { ?>
<?php echo $stars; ?>/5 <?php _e('stars', 'dt_theme'); ?> <?php _e('from', 'dt_theme'); ?> <?php echo $number_of_reviews; ?> <?php _e('reviews by', 'dt_theme'); ?> <?php echo ' '; ?> <?php if( !empty($stars) ) : _e('Amazon.ca customers ', 'dt_theme'); endif;?>
<?php } else { ?>

and
<button class="btn-custom <?php if (empty($buy_now_url)) : echo 'full'; endif; ?> collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseBuyNow" aria-expanded="false" aria-controls="collapseBuyNow" id="headingBuyNow">
<?php if (!empty($buy_now_url) || IS_DT_NZ_SITE) : ?>
<?php echo translateTheme('Find Online'); ?>
<?php else : ?>
<?php echo translateTheme('Buy Now'); ?>
<?php endif; ?>
</button>

Is there any wrong with my code? For other words, it works properly. It's really weirld.

wpml3.png
January 3, 2024 at 6:57 am #15145269

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

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

I see you are using a custom function translateTheme() to output the button text. I would like to inform you that helping you with custom code, is out of the scope of WPML. However, I suggest you try using the gettext function __() to register the button text for translation. For example:

<?php echo __('Buy Now', 'dt_theme'); ?>

then go to WPML > Theme and plugins localization > Scan strings in the child theme and translate it.

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

If you are not able to accomplish this, I would recommend you contact one of our certified partners who will be more than happy to help you with this. In this link, you will find a list of our certified partners: https://wpml.org/contractors/

Look forward to your reply.
Thanks

January 3, 2024 at 7:39 am #15145319

maraM-4

Hi Long,

Unfortunately, I attempted to implement your suggestion (<?php echo __('Buy Now', 'dt_theme'); ?>), but it still didn't work.

January 3, 2024 at 8:19 am #15145419

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

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

I would like to request temporary access (wp-admin and FTP) to your site to 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.

Look forward to your reply.
Thanks

January 3, 2024 at 9:51 am #15145648

maraM-4

Hi Long,

I've tried cloning the live production to a dev environment. I noticed that the problem only occurs on the live production. Please see the attached images.

So, what's the real issue?

wpml2.png
wpml1.png
January 4, 2024 at 1:11 am #15148998

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

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

Hi,

It looks like a sort of cache, please try to clear them all (browser, plugin, hosting, Cloudflare ...) and recheck the issue. Or you can push the data from the dev site to the live site and see if it works.

If not, I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. 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/

Look forward to your reply.
Thanks

January 4, 2024 at 7:27 am #15149353

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

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

Hi,

This happens because the plugin "Performant Translations" is activated on your site. I deactivate it and the translation string is displayed correctly in the frontend.
Can you please confirm it works on your end?

January 4, 2024 at 9:19 am #15149675

maraM-4

Hi Long,

I confirm that it's working on my end. Thank you for your support! You're a hero!