The following is the issue that I am facing -

- I have a multilingual site with two languages - English (default) and Spanish
- I have a taxonomy vocabulary named "Keywords". Under the "Translation mode", the "Translate. Different terms will be allowed for each language and they can be translated." option is selected.
- I have a content type named "Document" and a term reference field is added that refers to the "Keywords" vocabulary. The widget type is "Autocomplete term widget (tagging)".
- I created an English node, say "EN: Node" and put a new term "Term1". The term will be added.
- I create a Spanish node, say "ES: Node". In the node create form the term "Term1" will not show up, which is correct. However I can put the term "Term1", since it's free tagging field.
- A new Spanish term "Term1" is not created, rather the existing English term "Term1" is used, which is wrong.

Is this issue fixable?

CommentFileSizeAuthor
#1 fix_autocreate_language.patch2.56 KBrp7

Comments

a6hiji7’s picture

Issue summary: View changes

Fixed grammar

rp7’s picture

StatusFileSize
new2.56 KB

I can confirm this issue.

The root of the problem lies in taxonomy_autocomplete_validate . An autocreate term is not given a language, thus it's always saved under the default language (and not the language of the parent the term is being created in).

AFIAK simply adding a save/presave hook won't work, since we don't know what context we're saving the term in (eg. we don't know the language of the parent entity). I ended up overwriting the taxonomy_autocomplete_validate function. See patch attached.

IMO this needs a higher priority, changing it to major.

rp7’s picture

Priority: Normal » Major
a6hiji7’s picture

Thanks for confirming the issue. As I was not getting any replies, I tried to get to the cause of the issue myself. I too thought that the issue is with taxonomy_autocomplete_validate. However on further checking I found that the issue could be in i18n_select_query_term_access_alter function in the i18n_select module. That function has the check i18n_select_check_query($query, 'tid'), but for autocomplete terms, the tid field is not there in query.

a6hiji7’s picture

On further checking, the issue is with the i18n_select_check_query($query, 'tid'). Well, it may not actually be an issue but a limitation. This function returns FALSE if the query has the IN operator and because of that the query is not altered for adding the language.

rp7’s picture

To be honest, I still think the root is in taxonomy_autocomplete_validate. The autocreated term is always saved under the default language, not the language of the node we are creating/editing (you can easaly see this in the taxonomy_term_data table). i18n_select shouldn't come into play here (since it's content creation).

Perhaps we're talking about a different problem.

a6hiji7’s picture

No, I am not talking about a different problem. The term is saved with the correct language. So if I add the term in Spanish, it is saved as a Spanish term. But if I then add the same term in English, a new English term should be created, but it is not, the earlier Spanish term is referred. I am not sure if the core taxonomy module can handle the language. I think this can be handled by i18n_select. Regarding taxonomy_autocomplete_validate, it has a call to taxonomy_term_load_multiple, depending on the return value of which, it is decided whether the term is to be added. Since i18n_select implements i18n_select_query_term_access_alter, it can alter the query for loading the terms. It does it fine, except in the case of autocomplete term reference fields.

jose reyero’s picture

Status: Active » Closed (duplicate)

Basically, tagging is not working because we are not handling all that taxonomy autocomplete hooks. This needs to be addressed somehow globally so marking this as duplicate of #1085190: Make taxonomy autocompletion work / tagging / block tagging ?

jose reyero’s picture

Issue summary: View changes

Highlighted main issue