qtranslate-xt icon indicating copy to clipboard operation
qtranslate-xt copied to clipboard

fix missing menu_items with no translation

Open charroma opened this issue 1 year ago • 3 comments

Prevent menu items (taxonomy) being removed from menus when the term title is the same as the default language and the options "Show menu items in an alternative language when translation is not available for the selected language." is selected.

charroma avatar Aug 19 '24 19:08 charroma

@herrvigg

sviluppomania avatar Sep 15 '24 16:09 sviluppomania

@charroma The change looks fine at first sight, but I don't understand this description:

Prevent menu items (taxonomy) being removed from menus when the term title is the same as the default language

Since the check is on

$item_title = $q_config['term_name'][ $term->name ][ $language ] ?? '';

This is not about the default language but the current language?

when the term title is the same as ...

Where is that comparison done? The check seems to be on missing translation, but the case is for a non-multilingual item so I'm getting really confused.

herrvigg avatar Mar 12 '25 19:03 herrvigg

@herrvigg I added the same concept for the post title a little before in the file but didn't commit it.

There is no comparison done. It's just a check for non translated content and the admin content preference.

I noticed some pages and terms not showing in the menus because there was no translation saved in the current language.

The item title is empty because there is no translation saved. It always happens when I only save the title of a post or taxonomy in one language because it's the same in all language. So when the translation is not found, the code get the original title instead. It works fine on title and content, but in the navigation, the item disapeared.

The line make the non translated item as an empty string: $item_title = $q_config['term_name'][ $term->name ][ $language ] ?? '';

When it's empty and the user wants to show the alternate languague, the orinigal title is shown. Without this, non translated menu items are not shown. if ($item_title == '' && $q_config['show_menu_alternative_language']) {

charroma avatar Mar 12 '25 21:03 charroma