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?
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | fix_autocreate_language.patch | 2.56 KB | rp7 |
Comments
Comment #0.0
a6hiji7 commentedFixed grammar
Comment #1
rp7 commentedI 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.
Comment #2
rp7 commentedComment #3
a6hiji7 commentedThanks 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 ini18n_select_query_term_access_alterfunction in thei18n_selectmodule. That function has the checki18n_select_check_query($query, 'tid'), but for autocomplete terms, the tid field is not there in query.Comment #4
a6hiji7 commentedOn 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.Comment #5
rp7 commentedTo 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.
Comment #6
a6hiji7 commentedNo, 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.
Comment #7
jose reyero commentedBasically, 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 ?
Comment #7.0
jose reyero commentedHighlighted main issue