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.

Tagged: 

This topic contains 14 replies, has 2 voices.

Last updated by Mykola Kareiev 3 years ago.

Assisted by: Nicolas V..

Author Posts
January 27, 2023 at 8:28 pm #12906595

Mykola Kareiev

I'm importing products into the site using the WP all import plugin in the site's main language. The site is in 3 languages. The import is successful and my products are visible on the site in the main language. But WPML doesn't start automatically translating them. In the settings it is indicated to translate everything.
If I go to the product and click update - WPML will immediately automatically translate the product
What do I need to do to make WPML automatically translate products after import

January 28, 2023 at 12:21 pm #12908863

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Welcome to the WPML support forum. My name is Nicolas and I will be happy to help you today.

Unfortunately this is expected behavior, as my colleague explained here: https://wpml.org/forums/topic/automatically-translated-products-added-using-wp-all-import/

Imported posts (any post type) can not get automatically translated. This is expected behavior. To get the imported posts translated automatically, you need to go to Translation Management and send the imported posts to translation.

Nico

January 28, 2023 at 7:21 pm #12909611

Mykola Kareiev

Hello Nicolas,
Thank you for a answer.
1) Also, can you tell me, please, if i can programmatically send products to translating, after i import products
2) And one more things, when i done my first import - i use Microsoft translating service, but i was not satisfied with the results. Then i removed imported products, changed translation service to Google instead of Microsoft. And repeat import again, with exactly same file and products in there.
But the translation came out exactly the same as from Microsoft and my credits were not spent.
I believe it might be some sort of translation cache. Can you tell me how can I make a new translation for these products with Google Translate?

Thank you in advance

January 28, 2023 at 8:45 pm #12909783

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

1. The standard WordPress hook 'save_post' triggers WPML to check for updates on translation. It should be enough to send them to automatic translation.

Ref: https://developer.wordpress.org/reference/hooks/save_post/

2. ATE comes with a "Translation memory" and is able to detect if a segment has been translated before and use that translation in order to save credits. I've cleared your translation memory. It can some time to be completely deleted so please wait few hours before trying to translate.

January 31, 2023 at 6:43 pm #12932937

Mykola Kareiev

I'm sorry but I still need help
I'm trying to get my products to auto-translate by programmatically updating the product and running the save_post hook.
I've tried several different options and they update the product parameters successfully, but WPML still doesn't start auto-translating these products. But if I go in and manually click to update the product - WPML will automatically translate immediately
What is the problem?
Here is my code.
There are 2 functions here:
1) Updates the product when visiting any page of the site, but it does not bring results with WPML automatic translation
2) After each post created with WPAllImport, it runs the save_post hook, also without success

function test_script()
{
    $post_id = 3597;
    $post = get_post($post_id);
    wp_update_post(array(
        'ID' => $post_id,
        'post_content' => '',
        'post_status'   => 'publish',
    ));
    do_action("save_post_product", $post_id, $post, true);
    do_action('save_post', $post_id, $post, true);
}
add_action("wp_head", "test_script", 0);

function my_saved_post($post_id, $xml_node, $is_update)
{
    $import_id = wp_all_import_get_import_id();
    if ($import_id == '5' && $is_update == false) {
        $post = get_post($post_id);
        do_action('save_post', $post_id, $post, false);
    }
}
add_action('pmxi_saved_post', 'my_saved_post', 10, 3);
January 31, 2023 at 10:07 pm #12933533

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Please kindly note that custom code/work is out of the scope of our support but I escalated your ticket to the second tier support to see if they have any helpful feedback to help you out.

I'll get back to you as soon as I have an answer.
Nico

February 1, 2023 at 2:39 pm #12939201

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

In order for our dev team to have a closer look, we need to reproduce this scenario on our servers.

I have created this clean sandbox setup for you:
hidden link (one click login)

- I would need you to set up WPML + the WPML add-ons as you have them on your site (they are already installed) and to also install WP All import and try to recreate the issue.

Please don't install any other plugins that are not necessary to reproduce the issue.

Thanks,
Nico

February 1, 2023 at 6:09 pm #12941387

Mykola Kareiev

I sandboxed the core functionality of my site and everything works great. So the problem is in my site. I will further disassemble it myself, recreating my site gradually in the sandbox, to determine at what stage the problem occurs.
Thank you very much for your help!

February 1, 2023 at 7:30 pm #12941765

Mykola Kareiev

I found what my problem is. Automatic translation does not work when using php8.0+.
I created a new WP on my server and put only Woocommerce, WPML and WPAllImport there. The theme is 2021. And did some tests on different versions of PHP.
On PHP version 7.4 everything works fine. As soon as I switched the site to php 8.0 or higher, automatic translation stopped working after import.
I think you might find this information helpful as I didn't see PHP version restrictions in the WPML requirements.

February 1, 2023 at 8:23 pm #12941897

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

To clarify, the issue appears when you upgrade to PHP 8+ only on your production site or even on your sandbox?

If it happens on both, then it could be an issue compatibility with our plugin WPML All Import. In that case I need to report it as soon as possible.

Do you mind providing us a Duplicator copy of your sandbox to run some tests?
For this, you need to temporarily install a plugin called “Duplicator” on your site. This will allow you to create a copy of your site and your content.
I have activated a private field for you where you can share those files (package + installer).
- You can exclude /wp-uploads from the copy to reduce the size
- Once the package is ready, if the files are too large to upload them to the private field, you can share a link to Google Drive, Dropbox, WeTransfer or any other similar service.

Once the problem is resolved I will delete the local site. Let me know if this is ok with you.
https://wpml.org/faq/provide-supporters-copy-site/

Nico

February 2, 2023 at 3:04 am #12942933

Mykola Kareiev

The problem is definitely with your WPML All import plugin.
I just disable the plugin and the automatic translation worked with php 8.0+
Even without my custom code we talked about before

February 2, 2023 at 1:48 pm #12947961

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for testing this thoroughly and sharing your findings. I have forwarded your feedback to the second tier support team and will get back to you as soon as possible.

Nico

February 4, 2023 at 12:23 pm #12960521

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Thanks for reporting this issue, it has been escalated to the dev team. In the meantime here is a workaround:

The workaround is to comment-out the calls in the file wp-content/plugins/wpml-all-import/classes/WCML.php

add_action( 'deleted_post_meta', [ $this->getWCMLSynchronizeProductData(), 'delete_empty_post_meta_for_translations' ], 10, 3 );

and

remove_action( 'deleted_post_meta', [ $WCMLSynchronizeProductData, 'delete_empty_post_meta_for_translations' ], 10, 3 );

Could you please confirm that this solves your issue?
Nico

February 4, 2023 at 2:15 pm #12960727

Mykola Kareiev

Hello Nico
I checked and it fixed the problem. Products are now translated automatically
Thank you!