I know I can simply add language to displayed title of a node in Entity Reference field based on views. What I failed to discover is how to limit possible values to only show and allow matching ones.
When current node is language independent, all nodes should be listed as possible in reference field.
When node has language defined, only nodes of the same language, or undefined language, should be available.
I don't really mind wrong selection to be saved in database if language of node will be changed, as it shouldn't happen often enough to be a problem. I simply don't want "wrong" nodes on the list of available reference choices. On-save validation would be nice, but isn't a must-have.
I tried to use view to populate entityreference field's dropdown on node edit form:
My big block is how to access a language of a current node in view that provides list of available entities. I can't find a way other than to guess using current UI language, but that may be wrong for edits and usually is wrong on new node creation. Ideally, the entity reference field should repopulate via AJAX according to the language selected in the node edit from.
For the sake of future visitors I would appreciate complete answer. Of course answer not based on views will be appreciated, too.