1

I have a website in English.

I need to put all the nodes of all contentypes into another language so that the client is only responsible for entering and modifying data.

I know how to go through the nodes, I know how to create a translation of a node but I do not know how to duplicate all the fields of a node in the translation.

How could I do it?

With this code i create a translation from a node

$node = \Drupal\node\Entity\Node::load($value_rowToTranslate->nid->value);

$translation = $node->addTranslation('es');
$translation->title = "Titulo traducido";
$translation->field_1 = "dasdas"
$translation->field_2 = "xxxxxxxxx"
...
$translation->field_N = "xxxxxxxxx"

$translation->save();
4

1 回答 1

2

问题已在此处得到解答:https ://drupal.stackexchange.com/questions/270121/create-translated-node-programmatically

$node->addTranslation('de', $node->toArray());
于 2018-10-15T14:46:40.667 回答