function i18n_node_select_translation in Internationalization 7
Same name and namespace in other branches
- 6 i18n.pages.inc \i18n_node_select_translation()
Form to select existing nodes as translation
This one uses autocomplete fields for all languages
1 string reference to 'i18n_node_select_translation'
- i18n_node_translation_overview in i18n_node/
i18n_node.pages.inc - Overview page for a node's translations.
File
- i18n_node/
i18n_node.pages.inc, line 131 - User page callbacks for the translation module.
Code
function i18n_node_select_translation($form, &$form_state, $node, $translations) {
$form['node'] = array(
'#type' => 'value',
'#value' => $node,
);
$form['translations'] = array(
'#type' => 'fieldset',
'#title' => t('Select translations for %title', array(
'%title' => $node->title,
)),
'#tree' => TRUE,
'#theme' => 'i18n_node_select_translation',
'#description' => t("Alternatively, you can select existing nodes as translations of this one or remove nodes from this translation set. Only nodes that have the right language and don't belong to other translation set will be available here."),
);
foreach (i18n_node_language_list($node) as $langcode => $language_name) {
if ($langcode != $node->language && $langcode != LANGUAGE_NONE) {
$nid = isset($translations[$langcode]) ? $translations[$langcode]->nid : 0;
$form['translations']['nid'][$langcode] = array(
'#type' => 'value',
'#value' => $nid,
);
$form['translations']['language'][$langcode] = array(
'#type' => 'value',
'#value' => $language_name,
);
$form['translations']['node'][$langcode] = array(
'#type' => 'textfield',
'#maxlength' => 255,
'#autocomplete_path' => 'i18n/node/autocomplete/' . $node->type . '/' . $langcode,
'#default_value' => $nid ? i18n_node_nid2autocomplete($nid) : '',
);
}
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['update'] = array(
'#type' => 'submit',
'#value' => t('Update translations'),
);
//$form['buttons']['clean'] = array('#type' => 'submit', '#value' => t('Delete translation set'));
return $form;
}