Skip Navigation

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

Problem:
The client is trying to translate attributes from English to other languages like French. They have already translated all attributes via the taxonomy translation and string translation tabs. However, the attributes in the 'Add existing' dropdown are displayed in English instead of French. After selecting an attribute, it then displays in the translated language.

Solution:
We recommend adding a custom filter to the theme's

functions.php

file to translate the attribute labels. Here are the steps to follow:

1. Open the

functions.php

file of your theme.
2. Insert the following code at the end of the file:

add_filter('woocommerce_attribute_taxonomies', 'testtranslateattributenew');<br />function testtranslateattributenew($found_product_categories){<br />    $my_current_lang = apply_filters('wpml_current_language', NULL);<br />    foreach ($found_product_categories as $key => $cat){<br />        $found_product_categories[$key]->attribute_label = apply_filters('wpml_translate_single_string', $cat->attribute_label, 'WordPress', 'taxonomy singular name: '. $cat->attribute_label , $my_current_lang );<br />    }<br />    return $found_product_categories;<br />}

3. Save the changes.
4. Go to 'Users > Profile' in your WordPress Dashboard.
5. Enable the option 'Set admin language as editing language.'
6. Update the changes.

After applying this code, create a product in the second language and check the Attribute dropdown. The translated attribute should now appear in the dropdown list in the correct language.

Please note that this solution might be outdated or not applicable to your case. If the issue persists, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If necessary, please open a new support ticket for further assistance.

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

Last updated by Prosenjit Barman 1 year, 1 month ago.

Assisted by: Prosenjit Barman.

Author Posts
February 14, 2024 at 3:00 pm #15303151

aboubacarS

I am trying to: Translate attributes from English to other languages like French (I already translated all attributes from English to French via the taxominy translation Tab and the string translation Tab)

Link to a page where the issue can be seen: hidden link (short video link)

I expected to see: Attributes displayed in French and not in English

Instead, I got: Attributes are displayed in English (original language)

February 15, 2024 at 11:18 am #15306606

Prosenjit Barman
Supporter

Languages: English (English )

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

Hello There,
Thanks for contacting WPML Support.

I understand the problem you're having. Please note that when attributes are added to a default product and that product is translated, the corresponding translated attributes should automatically be associated with the translated product. There should be no need to manually assign the translated attributes.

However, if you've translated the attribute and it's not appearing in the product editor interface for the secondary language, synchronizing the attributes might help in this matter. Could you please try the following steps?

- Navigate to "WooCommerce > WooCommerce Multilingual > Attributes".
- Choose the attribute you're concerned with.
- Look for a button labeled "Synchronize Attributes" at the bottom of the page and click it. Please wait until the synchronization is complete.

I hope it will help. But, if the problem continues, it would be helpful if you could create a new product, assign some attributes, translate it, and then check whether the translated attribute is visible in the translated product.

Please let me know the update. I will be happy to help if you need further assistance in this matter.

Best regards,
Prosenjit

February 15, 2024 at 2:11 pm #15307667

aboubacarS

Hello,
Thanks for your feedbacks. I have already followed all your recommendations, but the issue is still occured. The issue doesn't concern translated products, all the attributes are well translated for them. The issue is about only the dropdown in the placeholder "Add existing". It displays the attributes in the original language (English). But after selected an attribute, it displays in the translated language (French).
Short video link : hidden link
Best regards

February 16, 2024 at 8:33 am #15310446

Prosenjit Barman
Supporter

Languages: English (English )

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

Hello There,

Thank you for sharing the video and additional details about the issue.

I've checked and successfully been able to reproduce the issue in our development environment.

I've already escalated the issue to our 2nd tier team for further investigation. As soon as I have more updates on this, I will surely let you know.

Just a quick tip: When using the WooCommerce Multilingual plugin with WPML, we strongly advise using the Translation Editor for adding or updating translations. This is particularly important for WooCommerce Products, where manual updates are not recommended. Consequently, the issue you're having with Attributes should have minimal impact, as your product translations will be conducted through the Translation Editor rather than using the native WordPress editor. The translated attributes will be applied to the Translated product after completing the Translation. I hope you can understand.

I appreciate your patience and kind cooperation while we're working on this issue.

Best regards,
Prosenjit

February 16, 2024 at 1:05 pm #15311735

aboubacarS

Hello Prosenjit,
Thanks for your support. Indeed, i always use the Translation editor for adding or updating translations rather than WordPress editor.

Best regards
Aboubacar

February 19, 2024 at 3:54 am #15315850

Prosenjit Barman
Supporter

Languages: English (English )

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

Hi Aboubacar,
I hope you're doing well. Sorry for the delay in responding due to the weekend.

Our development team has looked into the matter and verified that the attributes in the dropdown have been displayed this way since the beginning. However, I'm happy to inform you that we've identified a solution to this issue. To solve the issue, please follow these steps:

- Please open the "functions.php" file of the theme, insert the following code at the end, and save the changes.

add_filter( 'woocommerce_attribute_taxonomies', 'testtranslateattributenew');
function testtranslateattributenew($found_product_categories){
	$my_current_lang = apply_filters( 'wpml_current_language', NULL );
	foreach ($found_product_categories as $key => $cat){
		$found_product_categories[$key]->attribute_label = apply_filters('wpml_translate_single_string', $cat->attribute_label, 'WordPress', 'taxonomy singular name: '. $cat->attribute_label , $my_current_lang );
	}
	return $found_product_categories;
}

- Once added, go to "Users > Profile" from your WordPress Dashboard and enable the option "Set admin language as editing language." Update the changes.

After making the adjustments mentioned above, try to create a product in the second language and examine the Attribute dropdown. If the Attribute has been translated, it should appear in the Dropdown list in its translated form. I have tested this solution and can confirm its effectiveness in my development setup. Hopefully, the solution will be included in the future version of the WooCommerce Multilingual plugin.

Please let me know the update. I'll be happy to help if you need further assistance in this matter.

Best regards,
Prosenjit

February 19, 2024 at 4:56 pm #15319630

aboubacarS

Hello Prosenjit,

Many thanks for your support. The issue is resolved now.
Waiting for the official update in the plugin.

Best regards

Aboubacar