Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taxonomy term title doesn't get saved properly when the translated title is the same in multiple languages #1215

Closed
Kevin-JP opened this issue Aug 24, 2022 · 8 comments · Fixed by #1230
Labels
core Core functionalities, including the admin section severity: minor Minor functionality

Comments

@Kevin-JP
Copy link

Kevin-JP commented Aug 24, 2022

Hi,

I've searched all over the internet and didn't find any thread related to this specific issue.

So lets say I have French and German as languages and I have a taxonomy term with the title "Test" in french and "TestDE" in german.

Whenever I try to change the german title back to "Test" it doesn't get saved properly and it always keeps the old title "TestDE".
This issue only occurs when I pick exactly the same title as in the other language. For example if I try to change it to "TestDE2" it works.

One workaround is to use [:fr]Test[:de]Test[:] but it isn't always easy for the customer to use.

I'm also using the latest version of qtranslate-xt.

I hope anyone could help me here, many thanks in advance.

@Kevin-JP Kevin-JP changed the title Taxonomy title doesn't get saved properly when the translated title is the same in multiple languages Taxonomy term title doesn't get saved properly when the translated title is the same in multiple languages Aug 24, 2022
@spleen1981
Copy link
Contributor

spleen1981 commented Oct 3, 2022

What is the "title" of a taxonomy term? Do you mean the name field?
Can't reproduce anyways, tested with name and slug fields both for taxonomy terms and posts, and same string can be set and saved properly both for primary-secondary and secondary-secondary languages.
Can you explain better and share QTX settings > Troubleshooting > Collect information output.

@spleen1981 spleen1981 added the need info The submitter must provide more info label Oct 3, 2022
@Kevin-JP
Copy link
Author

Kevin-JP commented Oct 3, 2022

Yes, sorry, I meant the name field.

I recorded a short video of it, hope it helps:
Screen Recording 2022-10-03 at 12 42 43 PM

Basically I have a taxonomy term with the following name :

  • "test" for english
  • "testDE" for german

Now whenever I try to change the german name back to "test" it still keeps the same name as before: "testDE".

Only workaround I found that doesn't require additional coding is to use "[:en]test[:de]test[:]".

Here is the Debugging Information:
{ "PHP_VERSION": "7.4.1", "WP_VERSION": "6.0.2", "QTX_VERSION": "3.12.0", "Plugins": [ "Advanced Custom Fields PRO 5.12.2", "Custom Post Type UI 1.13.1", "qTranslate-XT 3.12.0" ] }

{ "default_language": "en", "enabled_languages": [ "en", "de" ], "flag_location": "plugins/qtranslate-xt/flags/", "language_name": { "en": "English", "de": "Deutsch" }, "locale": { "en": "en_US", "de": "de_DE" }, "locale_html": { "en": "", "de": "" }, "not_available": { "en": "Sorry, this entry is only available in %LANG:, : and %.", "de": "Leider ist der Eintrag nur auf %LANG:, : und % verfügbar." }, "date_format": { "en": "%A %B %e%q, %Y", "de": "%A, \\d\\e\\r %e. %B %Y" }, "time_format": { "en": "%I:%M %p", "de": "%H:%M" }, "flag": { "en": "gb.png", "de": "de.png" }, "url_mode": 2, "use_strftime": 3, "filter_options_mode": 0, "language_name_case": 0, "detect_browser_language": true, "hide_untranslated": false, "show_displayed_language_prefix": true, "show_alternative_content": false, "hide_default_language": true, "use_secure_cookie": false, "header_css_on": true, "header_css": ".qtranxs_flag_en {background-image: url(http://local-wordpress.local/wp-content/plugins/qtranslate-xt/flags/gb.png); background-repeat: no-repeat;}\n.qtranxs_flag_de {background-image: url(http://local-wordpress.local/wp-content/plugins/qtranslate-xt/flags/de.png); background-repeat: no-repeat;}\n", "text_field_filters": [], "term_name": { "Conf": { "en": "Conf", "de": "ConfDe" }, "test": { "en": "test", "de": "test" } }, "disable_client_cookies": false, "ignore_file_types": [ "gif", "jpg", "jpeg", "png", "svg", "pdf", "swf", "tif", "rar", "zip", "7z", "mpg", "divx", "mpeg", "avi", "css", "js", "mp3", "mp4", "apk" ], "url_info": { "cookie_lang_front": "en", "cookie_lang_admin": "en", "cookie_front_or_admin_found": true, "scheme": "http", "host": "local-wordpress.local", "path": "/wp-admin/admin-ajax.php", "query": "action=admin_debug_info", "path-base": "", "wp-path": "/wp-admin/admin-ajax.php", "language_neutral_path": true, "http_referer": "http://local-wordpress.local/wp-admin/options-general.php?page=qtranslate-xt", "referer_admin": true, "doing_front_end": false, "lang_cookie_admin": "en", "lang_admin": "en", "language": "en", "set_cookie": false }, "language": "en", "editor_mode": 0, "highlight_mode": 1, "auto_update_mo": true, "hide_lsb_copy_content": false, "lsb_style": "Simple_Buttons.css", "config_files": [ "./i18n-config.json" ], "custom_i18n_config": [], "custom_fields": [], "custom_field_classes": [], "post_type_excluded": [], "admin_enabled_modules": { "acf": true, "all-in-one-seo-pack": true, "events-made-easy": true, "jetpack": true, "google-site-kit": true, "gravity-forms": true, "woo-commerce": true, "wp-seo": true, "slugs": false }, "translator": {}, "qtrans_compatibility": false }

{ "cookies": [], "navigator": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" }

@spleen1981
Copy link
Contributor

Ok, it happens when the translation is the same for all languages.
It should be fixed by #1230, which will have the same effect of filling in one string only for default language, leaving the other language fields empty.
Actually this can be already done manually from admin interface rather than using [:en]test[:de]test[:]

@spleen1981 spleen1981 removed the need info The submitter must provide more info label Oct 4, 2022
@Kevin-JP
Copy link
Author

Kevin-JP commented Oct 5, 2022

Your fix does seem to do the trick, thank you for your help.

Actually this can be already done manually from admin interface rather than using [:en]test[:de]test[:]

I also figured this out but the problem would have been the customer. Some of the sites I worked on have up to 4-5 different languages so I'm pretty positive that some customers wouldn't like this solution as it might not seem intuitive at the first glance for them.

I'll mark this issue as closed.

@Kevin-JP Kevin-JP closed this as completed Oct 5, 2022
@herrvigg
Copy link
Collaborator

This worked already fine for post titles, so the bug is specific to terms. I re-open the ticket.

@herrvigg herrvigg reopened this Oct 13, 2022
@herrvigg herrvigg added the core Core functionalities, including the admin section label Oct 13, 2022
@herrvigg
Copy link
Collaborator

herrvigg commented Oct 15, 2022

For clarification, the fix proposed in #1230 appears to work for the user with the taxonomy edit. But I will not merge it as it creates some regression with the data storage for all ML content, for example post title. When the content is the same for all languages, everything should be fused without ML tags.

This issue is specific to taxonomy and there is surely a bug in qtx_admin_taxonomy. I have observed there's something wrong here:

$langs = qtranxf_term_find_translations( $lang, $default_lang, $term, $taxonomy );

If the term is not multilingual, the sanitization retrieves some older ML translations and assign them to q_config['terms_sanitized'] for that term. This is very old code I don't understand well so it would take more time for a fix and I'm looking at other topics with strftime and PHP 8.1.

@spleen1981
Copy link
Contributor

Yes, this condition in qtranxf_term_sanitize_name_unslashed keeps on resuming the old translation if the new name is not multilingual in this scenario (pre_term_name hook through qtranxf_term_sanitize_name_db).
For this issue 2a1486f should do the job.
I think there are other scenarios where current behaviour in qtranxf_term_sanitize_name_unslashed is the intended one (qtranxf_term_get_args hook), as for terms the name translations are stored separately and db stored term name can be used to retrieve actual translations from qtranslate options (though I did not go into detail).

@herrvigg
Copy link
Collaborator

Looks good now! Updated fix merged in master.

@herrvigg herrvigg added the severity: minor Minor functionality label Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core functionalities, including the admin section severity: minor Minor functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants