0

I'm having two customs content types in D7, one row (A) and another (B) that aggregates (via entity reference) the rows into bundles of rows (e.g. tables).

I can have up to 40 rows in a table. I'm translating manually each row in several languages. And then I'm creating one node (lets say node 100) in English of type B aggregating the 40 rows (let's say nodes 1-40) in English, and another node 101 in French (a translation of the English node 100) that aggregates the nodes 41-80 which are a direct translation of the 1-40 rows.

I would like while adding node 101 in French as a translation of node 100(English) to already pre-fill the node 101 to aggregate the nodes 41-80 which are in french and a one to one translation of the 1-40 English row nodes.

The translated entity reference module cannot help me in my case.

I tried to find a hook for the "add translation" to prepopulate the screen where the node 101 is being created as a translation of the node 100, and then just having to fill in 1-2 other extra fields in French and save...

Now I have to find the 41-80 references by hand, and since I'm having several languages (5 currently) the work involved is immense...

How could I achieve what I need? is there a module already written? otherwise which hook shall I use? I couldn't find an add translation hook in D7 (I believe there might be one in D8). I just need to know which hook to use for adding a new translation, I think I can manage the rest (finding for each row the translation in the target language).

I also do not need to do anything upon editing the node 101 after it has been saved, thus I only need the hook used the first time the node 101 is being created as a translation of node 100.

Many thanks

0

The solution was to use the hook_node_prepare($node) and there to check if (!empty($node->translation_source))

The above are the conditions that must be filled in to be in the "add translation" event.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.