我到处寻找,但我找不到翻译豆子的方法。它们依赖于entity_translation,但这似乎不起作用:
$form_state['build_info']['args'] = array ( 0 => $bean );
$form_state['form_id'] = 'bean_form';
$form_state['entity_translation'] = array(
'form_langcode' => $newLangcode,
'source_langcode' => 'en',
'is_translation' => 1,
);
drupal_form_submit('bean_form', $form_state);
它没有做任何事情。我有什么想法可以错过吗?或者有没有比尝试提交表单更好的方法?
我的尝试基本上只是试图模仿这个页面上发生的事情:
/block/MY_BLOCK/edit/add/en/es
答案 0 :(得分:0)
让我永远找到这个:
$translation = array(
'translate' => 0,
'status' => 1,
'language' => $langCode, // here is the language you're translating to
'source' => 'en',
);
$bean = bean_load($bid);
$handler = entity_translation_get_handler('bean', $bean);
$values = array (
// i add the default values here, but you can add whatever you want
);
$handler->setTranslation($translation, $values);
bean_save($bean);