In #301736: Multilingual support for nodereference we tweaked the behaviour of nodereference fields when nodes are being translated. But significant issues were left unaddressed. What do we do when a new translation is created, when an existing translation is deleted or marked as needing updating, etc.? I'm wondering if we need a deeper solution to the problem of references to multilingual content.
What is a nodereference? Almost always (or effectively always?), it's a relationship between two pieces of content--not between particular translations. Consider a use case with two types of content, companies and products. What's important is that a product is associated with a company--not that some translation of the company in a given language is associated with some version of the product in the same language.
So, in most cases, what we in fact want to track is a relationship between translation set, which are identified by the nid of the source translation. So a node reference should indeed always be a relationship between two nodes identified by nids. But in the case of translation sets, I suspect, these should be the nids of the "source" translation--or, in other words, the tnids shared by all members of the translation sets.
By having a single relationship - translation set A has a reference to translation set X - we would avoid the major headaches of having to track and update many different relationships between particular translations. We would also avoid data duplication and redundency. And, in the fallback case of a single-language site, we would have what we've always had--a reference from one node to another.
But what would this look like in practice? It would require a significant refactoring of nodereference, and possibly of field handling in general. I'll give this some thought next week and see if I can sketch out an outline. Ideas or feedback meantime would be great!
Comments
Comment #1
aacraig commentedWhat is the status on this? Getting multi-lingual node references to work is going to be extremely important to me over the next few months, and I agree that this may be a valid way to go about getting it to work.
I would be happy to take part in any necessary dirty work in getting this functionality sorted out.
Comment #2
nedjoI'm seeing this issue as having two sides.
First (I'm thinking of this as 'left'), is the issue of how in general we attach fields to a piece of content by either individual translation or translation set. This part of the issue applies to all fields, so I've opened a new issue: #340355: Enable fields to be stored by translation set (tnid).
This leaves us with the 'right' side of the issue--how to make nodereferences to either an individual translation or a translation set.
Here, we can follow what has been done in e.g. flag module, where flag types can be designated as applying to translation sets or to individual translations.
Implementation ideas:
1. When creating a nodereference field, we designate the nodereferences as being to translation sets or to individual translations.
2. Nodereference fields set to reference individual translations function just as they do now.
3. When adding a nodereference for a field set to use translation sets, we get a select or autocomplete that is only for source translations (though the titles may be for translations in the current language, if available)
4. When viewing a nodereference field that uses translation sets, we see the translation in the language of the node we're viewing, if present; otherwise, the source translation.
Comment #3
momper commentedsubscribing
Comment #4
donquixote commented@nedjo (#2),
totally agree with your analysis as a two-sided problem.
"Left side" (referrer/origin):
I think this should be solved in a generic way for all CCK fields. The other issue has been closed as a duplicate of #367595: Translatable fields, but the new issue is very much focused on D7 - which might need a different solution than D6.
Until we have such a generic solution for D6, there used to be this shared values module. Not sure what happened to it - absorbed in i18n? #406386: D6 status
"Right side" (referee/destination):
Could we do this as a new and separate field type 'tnidreference' ? Or would we lose the benefit from the views integration and other stuff that already exists for nodereference? I imagine that a lot of this stuff would have to be rewritten anyway, if suddenly we are talking about tnids instead of nids.
-----
I would also like to point out that a tnid does not necessarily have to be identical with the nid of an existing node. The original node could have been deleted, and a new node could have taken that role - with an nid different from the tnid. I did a SELECT query on the db of an existing site, and found that the majority of tnids on that site were not matched by an existing nid. Probably this is different per site, but we really can't count on it.
Comment #5
nedjo@donquixote
Yes, i18n (internationalization) in D6 includes a submodule to synchronize field values among a translation set.
Re tnids with no matching nid, what is supposed to happen is that, when the original source translation is deleted and there are remaining translations, one of those is designated as the new source translation, see http://api.drupal.org/api/function/translation_remove_from_set/6. What you saw might reflect a bug or, maybe, values that predate D6?
Comment #6
donquixote commentedInteresting. Then I guess this needs a cleanup script. Or i do it manually with commandline sql.
Comment #7
donquixote commentedThis also means, any nodereference or tnidreference that is supposed to link to the tnid will have to be updated to refer to the new tnid.
Comment #8
alberto56 commentedSubscribing, thanks.