Skip Navigation

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

Problem:
You are trying to delete translations for languages that have been removed in WPML's language settings, but the system hangs with a rotating circle and the translations remain undeleted after refreshing the page.
Solution:
We recommend deleting all taxonomies and translated menus first, and then running the cleanup through WPML -> Languages. If this does not resolve the issue, you could use WP-CLI to delete the terms manually. Here is a script that might help:

#!/bin/bash<br /><br /># Function to get term IDs by taxonomy and language<br />get_term_ids_by_language() {<br />local taxonomy=$1<br />local language_code=$2<br />wp db query "<br />SELECT t.term_id<br />FROM $(wp db prefix)terms AS t<br />JOIN $(wp db prefix)term_taxonomy AS tt ON t.term_id = tt.term_id<br />JOIN $(wp db prefix)icl_translations AS icl ON tt.term_taxonomy_id = icl.element_id<br />WHERE tt.taxonomy = '${taxonomy}' AND icl.language_code = '${language_code}'<br />" --skip-column-names<br />}<br /><br /># Define the languages and taxonomies you want to delete<br />languages=("en" "fr" "es") # Replace with your language codes<br />taxonomies=("product_cat" "product_tag" "category" "post_tag" "nav_menu" "tax_translation_priority")<br /><br /># Loop through each language and taxonomy to delete terms<br />for lang in "${languages[@]}"; do<br />for tax in "${taxonomies[@]}"; do<br />term_ids=$(get_term_ids_by_language "$tax" "$lang")<br />if [ -n "$term_ids" ]; then<br />wp term delete "$tax" $term_ids<br />fi<br />done<br />done

If this solution does not apply to your case, or if it seems outdated, please check the 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. If you still need assistance, we highly recommend opening a new support ticket 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.

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by Bruno Kos 8 months, 4 weeks ago.

Assisted by: Bruno Kos.

Author Posts
May 28, 2024 at 12:23 pm #15678347

Lukas Cech

Background of the issue:
I was attempting to delete translations for languages that I had previously removed in WPML's language settings.

Symptoms:
When I try to delete the translations by clicking the 'X' next to a language's translations and confirming the deletion, the system hangs with a rotating circle for hours. After refreshing the page, the translations remain undelete.
hidden link

Questions:
Why does the deletion process hang when attempting to remove translations of removed languages?
What steps can I take to successfully delete these translations without the system hanging?

May 28, 2024 at 1:11 pm #15678592

Bruno Kos
Supporter

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

Timezone: Europe/Zagreb (GMT+01:00)

Let me know about the results of the staging site test.

May 28, 2024 at 2:50 pm #15679355

Lukas Cech

I have created a copy of my website
- deactivated all plugins but WPML
- activated the Twenty-twenty four theme

The issue is still there, same as on my last video above.

May 28, 2024 at 2:52 pm #15679361

Lukas Cech

If you add a private window here, I can give you temp access using a login link.

May 29, 2024 at 11:21 am #15683103

Bruno Kos
Supporter

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

Timezone: Europe/Zagreb (GMT+01:00)

Next reply set as private.

May 30, 2024 at 5:27 am #15685817

Bruno Kos
Supporter

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

Timezone: Europe/Zagreb (GMT+01:00)

I am checking this with our 2nd tier and will keep you posted.

May 30, 2024 at 1:31 pm #15688290

Bruno Kos
Supporter

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

Timezone: Europe/Zagreb (GMT+01:00)

I checked with our team and it is possibly this issue:
https://wpml.org/forums/topic/backend-keeps-telling-me-language-deletion-from-database-is-not-complete/#post-12578017

So: https://wpml.org/errata/taxonomies-are-not-deleted-with-the-delete-content-from-database-option/

So it would seem that the only solution would be to delete all taxonomies and translated menus and then run the cleanup through WPML -> Languages.

Can you try with one language?

June 2, 2024 at 9:35 am #15695308

Lukas Cech

I see, was hoping to avoid having to delete everything manually (this isn't just an issue with taxonomies, but at least 20+ different types of content - posts, products, pages, taxonomies, attributes, custom post types etc.).

But if it's a known bug (albeit the bug states only "taxonomies are not deleted" but in my case it's everything) https://wpml.org/errata/taxonomies-are-not-deleted-with-the-delete-content-from-database-option/

then I'll have to do it manually.

June 3, 2024 at 8:04 am #15696665

Bruno Kos
Supporter

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

Timezone: Europe/Zagreb (GMT+01:00)

Yes, unfortunately there doesn't seem to be another way at the moment because the logic that handles this in WPML doesn't work properly.

But if you delete taxonomies and Menus, Pages and other types of CPTs should get deleted.

June 3, 2024 at 9:28 am #15697079

Lukas Cech

Sorry, no luck - I have deleted:
- all post categories and tags
- all product categories and tags

for all three languages I want to delete, then deactivated the languages and clicked the X icon to delete the content - no change: the content appears deleted, but after page refresh, it's there again.

Do I have to manually delete all the 27 product attributes and their 100+ attribute values???

June 4, 2024 at 10:22 am #15701085

Bruno Kos
Supporter

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

Timezone: Europe/Zagreb (GMT+01:00)

Until the internal ticket is resolved by our developers, I'm afraid there isn't much left for me to recommend.

You could however try with WP-CLI, something like this:

#!/bin/bash

# Function to get term IDs by taxonomy and language
get_term_ids_by_language() {
local taxonomy=$1
local language_code=$2
wp db query "
SELECT t.term_id
FROM $(wp db prefix)terms AS t
JOIN $(wp db prefix)term_taxonomy AS tt ON t.term_id = tt.term_id
JOIN $(wp db prefix)icl_translations AS icl ON tt.term_taxonomy_id = icl.element_id
WHERE tt.taxonomy = '${taxonomy}' AND icl.language_code = '${language_code}'
" --skip-column-names
}

# Define the languages and taxonomies you want to delete
languages=("en" "fr" "es") # Replace with your language codes
taxonomies=("product_cat" "product_tag" "category" "post_tag" "nav_menu" "tax_translation_priority")

# Loop through each language and taxonomy to delete terms
for lang in "${languages[@]}"; do
for tax in "${taxonomies[@]}"; do
term_ids=$(get_term_ids_by_language "$tax" "$lang")
if [ -n "$term_ids" ]; then
wp term delete "$tax" $term_ids
fi
done
done