Currently, nodereference takes no account of the language of referenced nodes.
Use case: page A was created in English and has a nodreference field with three nodereferences, to stories in English. Two of these stories have Spanish translations while a third does not. A users is translating the node to Spanish.
Current behavior: the user is presented with a new copy of the node in which the English translations are selected as nodreferences.
In many cases, the desired behaviour will be, instead: The user is presented with a new copy of the page in which the two existing Spanish translations and the remaining English node (lacking a translation) are selected.
It looks like nodereference should respond in hook_field() to the 'prepare translation' op. I'll work on a patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | nodereference-multilingual.diff | 3.15 KB | nedjo |
| #2 | nodereference-multilingual.diff | 2.79 KB | nedjo |
Comments
Comment #1
yched commentedWhat worries me is that several legitimate behaviors are possible for this :
- use translated references, leave empty if they don't exist
- use translated references, leave the current ones if they don't exist
- always leave the current ones (what we have now)
We could easily clutter the field settings form with those.
Comment #2
nedjo@yched: yes, I'm not sure this justifies a configuration option. Maybe we can determine the most commonly expected behaviour.
One thing to consider is that many or most sites featuring multiple languages will be running one or another of the content filtering options offered by i18n or other modules. E.g., if the site is set with i18n to display only nodes of the current language, the current (English) options won't appear as nodereference options in a new Spanish translation because the
db_rewrite_sql()implementation filters them out. So in this case the 2nd and 3rd approaches aren't possible.Here's a patch that implements your 2nd approach, use translated references, leave the current ones if they don't exist.
Comment #3
yched commentedFair enough - I don't understand the patch, though:
you do that by altering $node->translation_source ??
Comment #4
nedjoGood question :) Here's a corrected patch that alters the $node rather than the translation_source.
(I've followed the current approach of returning an array of values from the 'prepare translation' op invocations. I couldn't quite see why this is needed, but when I tried to alter the$node reference I got unexpected results, so I guess that's why.)
Comment #5
yched commentedCommitted - thanks !
Comment #6
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #7
weseze commentedI have a problem with this patch. (it seems to be in the standard release now)
I have a node A that contains a node reference field to nodes of type B.
Node A is a mulitilingual node in 4 languages. Node B is NOT multilingual. (language neutral)
I created a node A checked a few references and then saved the node.
Then I translated that node. On the edit-view of the translated node, the references that were checked on the original are not checked in the translation.
Is this normal behaviour? Can this behaviour be changed? (with an option for example)
Comment #8
netsensei commentedThis is still not as it should be, I think.
I'm currently working on a multilingual setup (3 languages):
I created a content type A with a node reference to type B. The node reference field is required for type A. Multilingual support is disabled on both types which means all nodes should be language neutral by default.
Now, if I try to create a node of type A, then I can't select any nodes of type B to reference to. The select box is just empty.
If I turn the multilingual support for both types on, the nodes start popping up but only those that are translated in the current active language. So if I have 5 english nodes of which 3 are translated in french, I'm only going to get those 3 in the node reference field if I french is the current active language.
Not all content on a multilingual site is per se translatable: my use case is the creation of an Image content type and an Image Gallery it references type. Of course, you don't want to translate each node per language, you want those types to be language neutral.
Comment #9
twodI think I had the same problem as in #7, If the referenced node is language neutral and a translation is created the reference field will be empty or not checked depending on type.
I got around this by addding
starting on line 177 in nodereference.module. (Didn't create a patch as I'm not using the CVS version but the 6.x-2.1 release.)
The problem in #8 could probably be worked around by setting i18n to switch interface language when translating a node.
When i18n rewrites the queries it uses i18n_get_lang() and i18n_default_language(), which at least in D6 reads the $language global and then does its thing based on the language selection mode.
I think there's no way to tell it to use a specific language instead of the current/default. One could maybe do a quick hack by temporarily modifying the $language global, but I don't know if that will cause any side effects.
Comment #10
netsensei commentedI solved this issue by selecting 'current language and language neutral' in the multilingual system configuration. So that would be a work around the current interface language switch that prevents selecting language neutral nodes.
I wonder if this is good solution i.e. I suppose one might get into trouble if his/her views don't explicitly filter on a the current language.
Comment #11
twodI already have it set to "current language and language neutral".
Anyway, I noticed that there's a way to temporarily stop i18n from messing with the queries, or tell it to use a specific where-clause instead of one of its own. This is done via i18n_selection_mode().(http://code.developmentseed.org/i18n/api/function/i18n_selection_mode/dr...)
I also had a similar problem with the nodereferrer module, both these modules do their language selection when a node is saved/updated.
I had a node, A, in english with a translation to swedish, B, with a nodereference to node C which was language neutral.
Node C had a noderefferer field which only listed either node A or B, depending on which language I used when saving the node.
What I wanted was for node C to link back to either A or B, but depending on the visitor's current language.
I did this by calling i18n_selection_mode('off') before noderefferer finds which nodes refers to the current node. I then call 1i8n_selection_mode('reset') after the queries are run to re-enable the last used selection mode so it won't mess with other things.
Node C will then list both node A and C (I also had the field set to show referrers on translations of the node).
The final step is a bit of a hack, as I used the 'sanitize' operation of hook_field() in nodereferrer to basically extract all the node ids from the nodereferrer field, build a simple query like
SELECT n.nid, n.vid, n.title FROM {node} n WHERE n.nid IN (_List_of_ids_) ORDER BY _the_order_value_from_the_field. This was run through db_rewrite_sql() to let i18n do its langauge selection and db_query() to put only the nodes back in the field which match the languages which I want presented to the visitor.I don't like the extra two queries (the hook is run twice), but I feel its a necessary evil and I'm planning to do something similar to nodereference fields if I can't get them to play nice.
If anyone else is interested in this, I'll create a patch to show the exact steps I took. I hope there's a better way to do this though...
Comment #12
egbertb commentedsubscribing
Comment #13
tomsm commentedI have a content type with a node reference field.
When I add the node reference in English, I can choose between the node with their titles in English.
The node reference field is synchronized between languages, but the node reference is not translated when I view the node in Dutch or French.
When I edit the node in Dutch, the node reference titles are in Dutch. When I save the node and I return to the English version of the node, the node references are in Dutch.
The node references are synchronized but not translated.
Comment #14
thommyboy commentedhi there,
i think that's still an open issue. my i18n settings are set to 'current language and language neutral'
i have a node type A (language neutral) with a nodereference to a node type B (language neutral).
now i set node type A to german, save it and create an english translation. the nodereference-field
in the translation form is empty- i think it should be set t node type B as this one is set to
language neutral.
if I create a german and an english translation for node type B everything works fine- so it seems
that on translation the nodereference field is only preset when the referenced node exists in the
same language, "language neutral" seems to be ignored?
maybe someone could evaluate that?
regards
tom
Comment #15
markus_petrux commentedPlease see this: #523374: Multilingual nodereferences supporting language neutral nodereferences
Comment #16
srobert72 commentedI think problem still exists.
Same content translated in many languages can't reference same language neutral content.
Suppose you have Article contenttype translated in 3 languages.
Pictures gallery for one article should be in common for its 3 translations.
Actualy it's not possible to do so.