function i18n_taxonomy_translation_term_form in Internationalization 7
Produces a vocabulary translation form.
3 string references to 'i18n_taxonomy_translation_term_form'
- i18n_taxonomy_menu in i18n_taxonomy/
i18n_taxonomy.module - Implements hook_menu().
- i18n_taxonomy_page_vocabulary in i18n_taxonomy/
i18n_taxonomy.admin.inc - This is the callback for taxonomy translations.
- i18n_taxonomy_term_translation_page in i18n_taxonomy/
i18n_taxonomy.i18n.inc - Callback for term translation tab.
File
- i18n_taxonomy/
i18n_taxonomy.admin.inc, line 33 - Helper functions for taxonomy administration.
Code
function i18n_taxonomy_translation_term_form($form, $form_state, $vocabulary, $translation_set = NULL, $source = NULL) {
$form['translation_set'] = array(
'#type' => 'value',
'#value' => $translation_set,
);
$translations = $translation_set ? $translation_set
->get_translations() : array();
$form['vocabulary'] = array(
'#type' => 'value',
'#value' => $vocabulary,
);
$form['translations'] = array(
'#type' => 'fieldset',
'#title' => t('Select translations'),
'#description' => t('Select existing terms or type new ones that will be created for each language.'),
'#tree' => TRUE,
);
// List of terms for languages.
foreach (i18n_language_list() as $lang => $langname) {
if ($source && $source->language == $lang) {
// This is the source term, we don't change it
$form['source_term'] = array(
'#type' => 'value',
'#value' => $source,
);
$form['translations'][$lang] = array(
'#title' => $langname,
'#type' => 'item',
'#markup' => check_plain($source->name),
'#langcode' => $lang,
);
}
else {
$form['translations'][$lang] = array(
'#title' => $langname,
'#type' => 'textfield',
'#default_value' => isset($translations[$lang]) ? $translations[$lang]->name : '',
'#autocomplete_path' => 'i18n/taxonomy/autocomplete/vocabulary/' . $vocabulary->machine_name . '/' . $lang,
'#langcode' => $lang,
'#maxlength' => 1024,
'#element_validate' => array(
'i18n_taxonomy_autocomplete_validate',
),
);
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
if ($translation_set) {
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
}
return $form;
}