[Resolved] Unable to delete translations of removed languages
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.
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?
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.).
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???
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+02: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