I have a site with multiple languages, content translation and a fixed English backend. The module to filter the entityreference options in the autocomplete seems to be broken. It uses i18n_node_i18n_context_language() to determine the node language, but this functions checks for arg(0) which is entityreference in the case of the autocomplete call..

(I thought it had something to do with the field collections i was using, but this doesn't seem to be the case)

Comments

Koen.Pasman created an issue. See original summary.

Koen.Pasman’s picture

Title: Compatibility with field collections » Broken in autocomplete
Issue summary: View changes
Koen.Pasman’s picture

Title: Broken in autocomplete » Broken in autocomplete widget
anybody’s picture

Priority: Normal » Major

I can absolutely confirm this problem!

i18n_node_i18n_context_language() has "entityreference" as result of arg(0) and can't be used for this case, as it seems!

The module does not work at all for parent entity language.

anybody’s picture

The "q" parameter looks like this instead (node edit):
de/entityreference/autocomplete/single/field_xyz/node/article/873/MyEnteredAutocompleteSearch

(Node add:)
de/entityreference/autocomplete/single/field_xyz/node/article/NULL/MyEnteredAutocompleteSearch

where arg(0) is entityreference.

A $_GET['translation'] parameter is NOT available in this command.

anybody’s picture

Finally this module is not able to work as expected currently for the described situation. I have no idea how to solve that or how that ever worked.

sleepingmonk’s picture

Changed to i18n_language_content() and added a join (entity_translation) to the query to include referenced items that are also translated into the target language.

sleepingmonk’s picture

StatusFileSize
new1.98 KB

Realized that changing to i18n_language_content() did basically the same as setting the field to "Select all nodes matching interface language".

Removed that change and made the or/join conditional on the existence of entity_translation.

Added the or/join to the query condition for "Select all nodes matching interface language" setting as well.

(This may now be a different issue.)

sleepingmonk’s picture

Status: Active » Needs review
StatusFileSize
new2.1 KB

After further discussion with my colleagues, I've added the change to i18n_language_content() back in for "parent language", given that the parent language for the node being referenced will be the current content language, and i18n_node_i18n_context_language() won't work on the autocomplete field.

This patch also still contains the check for entity_translation and additional join to return results if referenced nodes have translations in the correct language.

anybody’s picture

i18n_language_content() will not return the selected content language, will it?
It will return the current site language of the acting user?

chrlvclaudiu’s picture

I agree with #10. I've tested solution #9 and doesn't seem to work.

chrlvclaudiu’s picture

StatusFileSize
new1.09 KB

Hey, why not using the entity's language in this case ? I've attached a patch and any tests would be great.

rcodina’s picture

@hrlvclaudiu Your patch doesn't work for me because I use "Internationalization" and "Content Translation" to translate my site. I think a patch must support both ways of translation (Content Translation and Entity Translation). Also, notice the module dependencies on info file.

rcodina’s picture

Status: Needs review » Needs work
Nodz’s picture

The patch in #12 worked for me, but I only use "Internationalization" on that site.

It makes sense however that the solution would be optimal if it was aware of both ways of translation.

sleepingmonk’s picture

When checking entity translation table, the handler did not filter results by entity_type = node, which would return nodes of the wrong language in the autocomplete field, because other entities existed with matching entity ids.

This latest patch adds the condition to resolve this issue.

sleepingmonk’s picture

Koen.Pasman’s picture

Hm, sleepingmonks patch works for me if I remove the condition on et.entity_type. Needs some further testing though.

rcodina’s picture

I think that if you use Entity Translation you don't need this module, you just need to update Entity Reference module to latest version. Am I wrong? Check this out #1674792: Rendered entity is not language aware

matthieu_collet’s picture

yes #17 patch is working for me too when removing the condition on et.entity_type

and yes @rcodoina, I still need this module even if I use Entity Translation