I use entity_translation
and have an en
node currently without translations. Assume it has fields field_foo
and field_bar
so currently they are:
$node->field_foo['en'][0]['value'] = 'foo';
$node->field_bar['en'][0]['value'] = 'bar';
I want to programmatically add anfr
translation but only translate field_foo
so I do:
$node->field_foo['fr'][0]['value'] = 'foo FR';
entity_translation_get_handler('node', $node)->setTranslation(array(
'translate' => 0,
'language' => 'fr',
'source' => 'en'
), $node);
field_attach_update('node', $node);
This works but now if I edit (or devel) the fr
node, field_bar
is empty. On the frontend it does show "bar" which is the en
value, but I've noticed that if I create the translation via the Drupal UI then the field_bar
is not empty and contains a copy of the en
value.
So, does anyone know of a way that the API will copy all values upon translation creation? Or should I be doing that myself manually via the code?