Skip Navigation

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

Problem:
The client was unable to translate the name of a product variation in a WooCommerce site using WPML. Despite the translation being completed in the Advanced Translation Editor (ATE), the variation name still displayed in the original language on the front-end.

Solution:
We identified that the issue was related to a custom function in the theme's

functions.php

file, which incorrectly handled language information and prevented translations from being applied. We modified the function to ensure it checks for valid data before proceeding. Here's the corrected code snippet:

if (function_exists('wpml_get_language_information')) {<br />    $lang_info = wpml_get_language_information($post_id);<br />    // Check if we got a WP_Error<br />    if (is_wp_error($lang_info)) {<br />        error_log('WP_Error encountered in wpml_get_language_information: ' + $lang_info->get_error_message());<br />        return; // Stop execution if there's an error<br />    }<br />    <br />    if ($lang_info['language_code'] !== 'en') {<br />        return;<br />    }<br />}

After applying this fix, the product variation name displayed correctly in all languages. If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, please check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. We highly recommend opening a new support ticket if further assistance is needed. You can do so at WPML 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 8 replies, has 2 voices.

Last updated by Prosenjit Barman 3 weeks, 5 days ago.

Assisted by: Prosenjit Barman.

Author Posts
October 20, 2024 at 9:34 am #16308264

petrC-8

Background of the issue:
I am working on a WooCommerce site, hidden link, using WPML. We have a local product attribute and are creating variations from this local product attribute. The product variation has a set price, image, etc. Everything works well in alternative languages, except for the name of the variation.

Symptoms:
The variation name cannot be translated. For example, the attribute in English might be named: 'Variation of 20.' We can see this on the front-end in English, Spanish, and other languages, but there's no way to translate 'Variation of 20' into 'Paquete de 20.'

Questions:
How can I translate local product attribute names for variations in WPML?

October 20, 2024 at 9:44 am #16308347

petrC-8

I tried and it didn't help:

1: WPML -> Taxonomy translations - Resync Attributes: no effect

2: WPML -> Support -> Troubleshooting: Products - resync post taxonomies (completed with 10 products): no effect

3: WPML -> Support -> Troubleshooting: Clear the cache in WPML

Now, when I go back to product edit in English and click the Update Translation "eye icon" in Advanced Translation Editor, I can now see "Pack of 20" with its translation.

I hit Complete Translation, but it's still in English on the front-end.

Advanced Translation Editor - WPML 2024-10-20 11-41-45.jpg
October 20, 2024 at 9:53 am #16308388

petrC-8

Another weird thing is that in the Translation queue, the Variations are marked as Completed, but the Product is impossible to complete. Even when I hit Continue Reviewing and Complete translation in the Advanced Translate Editor, it's still in "Review in progress" state.

Translations ‹ Bitters — WordPress 2024-10-20 11-52-10.jpg
October 21, 2024 at 9:27 am #16311238

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
Thanks for contacting WPML Support.

I reviewed the product and noticed the issue. After checking the translation job in our system, I found that the translation is completed but hasn't been delivered to your site due to some issues. This seems to be why the text isn't displaying correctly in other languages.

Additionally, I noticed that the site has been moved from 'hidden link' to the main site, but the site key for the main site hasn't been updated yet. This could be causing issues with delivering the translation.

Please try updating the site key by following the steps below and check if that helps in solving the issue.

- Please go to Registered Sites section of WPMl and delete the site key for your main site. Click on the Trash icon(Screenshot: hidden link) and delete the site key.
- Once done, click on the "Add New Site" button and generate a new site key under the "Production" site
- After that, Log in to your site’s admin and go to "Plugins → Add New" and click the Commercial tab. Click on "Unregister WPML from this site".
- Once the page refreshes, insert the newly generated key into the Site key field and press the "Register" button.
- Once done, open the default product in the WordPress editor and make a small change there.
- Save the changes and proceed to update the translation.

Sometimes the firewall can also affect both inbound and outbound API requests, I recommend following the instructions in this guide and then trying to translate the product again.

I hope it will help. Please feel free to let me know if you need further assistance in this matter. I will be happy to help.

Best regards,
Prosenjit

October 21, 2024 at 11:25 am #16311937

petrC-8

Hi,
thanks for your response.
Still the same.

I made these changes:
1) Removed bts.weloveweb.eu from sites on WPML
2) Removed bitters.bio from sites on WPML
3) Unregistered WPML at bitters.bio
4) Added bitters.bio to sites on WPML
5) Registered with new site key WPML at bitters.bio
6) Made a change on the product's English (main) version
7) Saved changes
8) Redid a translation
9) Completed the translation

But it's still the same. Instead of "Paquete de 20", I still see "Pack of 20", even though in ATE it's correct.

Still missing this attribute in product attributes. Please see screenshots.

Edit product “Shirataki Spaghetti 390g” ‹ Bitters — WordPress 2024-10-21 13-23-01.jpg
Advanced Translation Editor - WPML 2024-10-21 13-21-33.jpg
October 22, 2024 at 4:20 am #16314897

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
Thank you so much for trying out the suggestions!

Since the attribute has been translated correctly, it should not be missing from the translated product. Upon reviewing the product again, the variation title appears to be displayed in the pricing section. This could indicate that the variation hasn't been synchronized properly, leading to the issue. Could you please try the following steps and see if they resolve the problem?

- Please go to WPML > Support > Troubleshooting
- Click on the following buttons:

=> Synchronize posts taxonomies [Select 'Variations' from the dropdown under "cleanup"]
=> Clear the cache in WPML
=> Remove ghost entries from the translation tables
=> Synchronize local job ids with ATE jobs
=> Synchronize translators and translation managers with ATE
=> Assign translation status to duplicated content
=> Set language information
=> Fix post-type assignment for translations

- After completing the steps, clear the cache from both your site and browser.
- Open the default product in the editor, make a small change to the attribute (for example, temporarily remove the attribute), save the changes, and update the product. Then, re-add the attribute, create the variations, save them, and update the product again. Afterward, update the product translation.
- Check if the title is still missing.

Please give it a try and let me know how it goes. I'll be happy to help if you need further assistance in this matter.

Best regards,
Prosenjit

October 22, 2024 at 7:49 am #16315374

petrC-8

I did exactly what you said and recreated the variation completely from scratch, but the results are the same.

Please try accessing the site yourself. Sending messages once a day is highly inefficient for us, and my client is not very happy with this situation.

I had to create a temporary solution and label this variation in the main English language as Czech (which is the most important market for my client, so you will now see the variation name as "Balení po 20 kusech"), but the issue persists. The translation is not visible in other languages (such as Spanish).

Even though I have this text translated into Spanish in ATE, the FE still shows the text from the English version (now in Czech).

We didn't have this issue when creating products for the first time. It's only happening now while editing the product.

Please try enter the site and do what is necessary by yourself . Sending messages once a day is highly inefficient for us, and my client is not very happy with this situation.

Shirataki Spaghetti 390g - Bitters 2024-10-22 09-47-12.jpg
Advanced Translation Editor - WPML 2024-10-22 09-46-59.jpg
Troubleshooting ‹ Bitters — WordPress 2024-10-22 09-34-04.jpg
Troubleshooting ‹ Bitters — WordPress 2024-10-22 09-33-16.jpg
October 23, 2024 at 3:05 am #16319734

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi There!
Thank you for patiently trying out all the suggestions!

As the issue persists, a closer inspection will be required to understand its root cause.

I 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.

You will find the needed fields below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” or "All in One WP Migration" on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved I will delete the local site. Let me know if this is ok with you.

IMPORTANT
-Please backup site files and database before providing us access.
-If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:
hidden link

Looking forward to your response.

Best Regards,
Prosenjit

October 24, 2024 at 3:32 am #16324098

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
Thank you for sharing the access details!

I've checked the issue and was able to identify the problem. In the `functions.php` file of your theme, the following condition in the `sync_price_and_sale_price_czk_to_translations_variations()` function was causing an error.

if ($lang_info['language_code'] !== 'en') {
    return;
}

This condition caused an error that prevented the translation from being applied correctly on your site. As a result, the default variation name was displayed in other languages instead of the translated version.

Here is the error that was logged:

Cannot use object of type WP_Error as array /home/u244214315/domains/bitters.bio/public_html/wp-content/themes/hello-theme-child-master/functions.php:37

The error occurred because the function used to check the product's language (`wpml_get_language_information()`) sometimes returns an error (WP_Error) when there’s an issue retrieving the language information. This can happen if the product ID is invalid or if there's a configuration problem. When the function returns an error, the code tries to process it like normal data, leading to this issue.

Although providing support of the custom coding is typically beyond the scope of our support, For now, i’ve fixed the issue by adding a check to ensure the function returns valid data before it is used. If an error is encountered, the system now logs it and stops further execution to avoid problems.

Here is the updated code:

if (function_exists('wpml_get_language_information')) {
    $lang_info = wpml_get_language_information($post_id);
    // Check if we got a WP_Error
    if (is_wp_error($lang_info)) {
        error_log('WP_Error encountered in wpml_get_language_information: ' . $lang_info->get_error_message());
        return; // Stop execution if there's an error
    }
    
    if ($lang_info['language_code'] !== 'en') {
        return;
    }
}

After making this update, I refreshed the Spanish and Czech translations for the product, and the variation name now displays correctly. You can check the result here: hidden link

I hope this resolves the issue. Please note that if you need further assistance with custom code, please consider hiring a developer. You can find experienced professionals on WPML's verified contractor list.

If you have any other questions or need clarification, feel free to let me know. I'll be happy to help!

Best regards,
Prosenjit

October 24, 2024 at 7:58 am #16324794

petrC-8

Wow! You are the best Prosenjit!!!!!
Thanks a lot!