You are here

function i18n_translation_mode_element in Internationalization 7

Get form element for translation mode and language

Parameters

$object_type: Object type for the container element

$i18n_mode: Current or default translation mode

$langcode: Current or default language code

$options: Restricted list of translation modes if we don't want all of them

2 calls to i18n_translation_mode_element()
i18n_menu_form_menu_edit_menu_alter in i18n_menu/i18n_menu.module
Implements hook_form_FORM_ID_alter().
i18n_taxonomy_form_taxonomy_form_vocabulary_alter in i18n_taxonomy/i18n_taxonomy.module
Implements hook_form_FORM_ID_alter()

File

i18n_translation/i18n_translation.module, line 118
Internationalization (i18n) module - Entity translations

Code

function i18n_translation_mode_element($object_type, $i18n_mode = I18N_MODE_NONE, $langcode = LANGUAGE_NONE, $options = NULL) {
  $form['i18n_translation'] = array(
    '#type' => 'fieldset',
    '#title' => t('Multilingual options'),
    '#collapsible' => TRUE,
  );
  $form['i18n_translation']['i18n_mode'] = array(
    '#type' => 'radios',
    '#title' => t('Translation mode'),
    '#options' => i18n_translation_options($object_type, $options),
    '#default_value' => $i18n_mode,
    '#description' => t('For localizable elements, to have all items available for translation visit the <a href="@locale-refresh">translation refresh</a> page.', array(
      '@locale-refresh' => url('admin/config/regional/translate/i18n_string'),
    )),
  );
  $form['i18n_translation']['language'] = array(
    '#default_value' => $langcode ? $langcode : LANGUAGE_NONE,
    '#description' => t('Predefined language. If set, it will apply to all items.'),
    '#required' => TRUE,
    '#states' => array(
      'visible' => array(
        'input[name="i18n_mode"]' => array(
          'value' => (string) I18N_MODE_LANGUAGE,
        ),
      ),
    ),
  ) + i18n_element_language_select();

  // The option value 'Language neutral' makes no sense here.
  $form['i18n_translation']['language']['#options'][LANGUAGE_NONE] = t('- Select a language -');
  return $form;
}