Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Asia/Singapore (GMT+08:00)

Tagged: 

This topic contains 21 replies, has 2 voices.

Last updated by Kor 9 months, 2 weeks ago.

Assisted by: Kor.

Author Posts
April 17, 2024 at 8:55 am #15530350

francescoF-25

Yeah, that's exactly why I was asking for support: is seems that WPML is incompatible with wp-cli regenerate and that's a huge deal breaker for any website owner that has more than, say, 200 images, which is pretty common these days, because using Regenerate Thumbnail for such a demanding task is not a feasible option.

So let's make it compatible, what do you think?

April 17, 2024 at 9:15 am #15530439

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

I have another feedback and this is what they mentioned.

WPML is not supposed to do anything with the attachment files. WPML handles only database entries. Extending the functionality to handle the files is definitely out of scope here and could create performance issues and it won't be desirable for most of the users.

April 17, 2024 at 9:23 am #15530508

francescoF-25

It does not have to handle files in any way and it's not what the issue is about. You're just bouncing a legit bug back.

WPML duplicates attachment IDs and the related attachment meta_value. When a original language attachment is regenerated via wp-cli, it's WPML that should hand the synchronization of the updated meta_value for the corresponding translated attachment ID.

There's anything to do with files, it's just a database entry that WPML should update in the postmeta table.

This is intended behaviour and it's in fact what happens when using Regenerate Thumbnail, because of it relying on action hooks that get triggered only in wp-admin environment and not on wp-cli environment.

This is what should be fixed, not files. I have never ever mentioned files.

April 17, 2024 at 2:13 pm #15532998

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

I've shared your feedback with our 2nd Tier Support. Will update you once I hear from them.

April 21, 2024 at 10:10 am #15546983

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for your patience.

I've received feedback from our 2nd Tier Support regarding your query. From their perspective, this appears to be more of a feature request.

I do have a tentative workaround that you may suggest to the user:

Navigate to the file: `wp-content/plugins/sitepress-multilingual-cms/classes/request-handling/class-wpml-language-resolution.php`

Within the method: `\WPML_Language_Resolution::filter_for_legal_langs`, insert the following condition:

if (defined('WP_CLI') && WP_CLI) {
    global $argv;
    $command_line = implode(' ', $argv); // Convert arguments to a single string

    // Check if 'wp media regenerate' is in the command line
    if (strpos($command_line, 'media regenerate') !== false) {
        $lang = "all";
    }
}

Insert the code snippet above just before the `return $lang;` line. This modification should ensure that when running `wp media regenerate`, elements from ALL languages are processed.

Please note:
- This solution might have some bugs.
- No warranties are provided with this workaround.

April 22, 2024 at 1:09 pm #15550670

francescoF-25

Hi Kor, I do not understand how this can be seen as a feature request, as wp-cli is pretty widespread in serious projects and I think that the Wpml team should acknowledge the issue, however i must thank you for reporting and insisting with the 2nd tier team.

I will run regenerate again on the test environment as soon as possible to let you know if it's working fine.

April 22, 2024 at 1:12 pm #15550692

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for getting back to me.

Okay, please keep me informed of any developments. Also, I've noticed that this report has been forwarded to our developers for review.

The topic ‘[Closed] Media Translation feature not working correctly’ is closed to new replies.