You are here

function lingotek_admin_additional_translation_settings_form in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.7 lingotek.admin.inc \lingotek_admin_additional_translation_settings_form()
  2. 7.3 lingotek.admin.inc \lingotek_admin_additional_translation_settings_form()
  3. 7.4 lingotek.admin.inc \lingotek_admin_additional_translation_settings_form()
  4. 7.6 lingotek.admin.inc \lingotek_admin_additional_translation_settings_form()

Additional translation form

1 call to lingotek_admin_additional_translation_settings_form()
lingotek_setup_additional_translation_settings_form in ./lingotek.setup.inc
1 string reference to 'lingotek_admin_additional_translation_settings_form'
lingotek_admin_configuration_view in ./lingotek.admin.inc

File

./lingotek.admin.inc, line 522

Code

function lingotek_admin_additional_translation_settings_form($form, &$form_state, $show_fieldset = FALSE) {
  global $base_url;
  $api = LingotekApi::instance();
  $setup_complete = !lingotek_is_config_missing();
  $account = LingotekAccount::instance();
  $show_advanced = $account
    ->showAdvanced();
  $title_str = $setup_complete ? t('Configuration Translation') : t('Which additional items do you want translated?');

  // Configuration translation (ie. taxonomies, menus, etc.)
  $form['additional_translation'] = array(
    '#type' => $show_fieldset ? 'fieldset' : 'item',
    '#title' => check_plain($title_str),
    //'#description' => t('Enable/disable and set defaults for comment translation.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => 'administrative_settings',
    'actions' => array(
      '#type' => 'actions',
      'submit' => array(
        '#type' => 'submit',
        '#value' => t('Save'),
      ),
    ),
    '#validate' => array(
      'lingotek_admin_additional_translation_settings_form_validate',
    ),
    '#submit' => array(
      'lingotek_admin_additional_translation_settings_form_submit',
    ),
  );
  $header = array(
    'Type',
    'Description',
  );
  $fr = array(
    '#id' => 'lingotek_use_translation_from_drupal',
    '#type' => 'checkbox',
    '#title' => t('Use Drupal community translations when available from <a href="@link">localize.drupal.org</a>', array(
      '@link' => url('http://localize.drupal.org', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
    )),
    '#attributes' => array(
      'id' => array(
        'lingotek_use_translation_from_drupal',
      ),
      'name' => 'lingotek_use_translation_from_drupal',
      'class' => array(
        'field',
      ),
    ),
    '#default_value' => variable_get('lingotek_use_translation_from_drupal', TRUE) ? 'checked' : FALSE,
  );
  $prep_blocks_chbx = array(
    '#id' => 'lingotek_prepare_config_blocks',
    '#type' => 'checkbox',
    '#title' => t('Update all blocks to be translatable in the Languages settings.'),
    '#attributes' => array(
      'id' => array(
        'lingotek_prepare_config_blocks',
      ),
      'name' => 'lingotek_prepare_config_blocks',
      'class' => array(
        'field',
      ),
    ),
    '#default_value' => 1,
  );
  $prep_taxonomy_chbx = array(
    '#id' => 'lingotek_prepare_config_taxonomies',
    '#type' => 'checkbox',
    '#title' => t('Update all taxonomy vocabularies to use translation mode \'Localize\' in the Multilingual Options. (Note: This will prevent translation of custom fields within taxonomy terms.)'),
    '#attributes' => array(
      'id' => array(
        'lingotek_prepare_config_taxonomies',
      ),
      'name' => 'lingotek_prepare_config_taxonomies',
      'class' => array(
        'field',
      ),
    ),
    '#default_value' => 1,
  );
  $prep_menus_chbx = array(
    '#id' => 'lingotek_prepare_config_menus',
    '#type' => 'checkbox',
    '#title' => t('Update all menus to use \'Translate and Localize\' in the Multilingual Options.'),
    '#attributes' => array(
      'id' => array(
        'lingotek_prepare_config_menus',
      ),
      'name' => 'lingotek_prepare_config_menus',
      'class' => array(
        'field',
      ),
    ),
    '#default_value' => 1,
  );
  $hidden_i18nviews_value = array(
    '#id' => 'lingotek_i18nviews_enabled',
    '#type' => 'hidden',
    '#value' => module_exists('i18nviews'),
  );
  if (variable_get('lingotek_use_translation_from_drupal', 0)) {
    $fr['#attributes']['checked'] = 'checked';
  }
  $options = array(
    'lingotek_translate_config_blocks' => array(
      t('Blocks'),
      t('Include translation for all translatable blocks.') . drupal_render($prep_blocks_chbx),
    ),
    'lingotek_translate_config_taxonomies' => array(
      t('Taxonomy'),
      t('Include translation for all translatable taxonomy vocabularies and terms.') . drupal_render($prep_taxonomy_chbx),
    ),
    'lingotek_translate_config_menus' => array(
      t('Menus'),
      t('Include translation for all menus set to \'Translate and Localize\'.') . drupal_render($prep_menus_chbx),
    ),
    'lingotek_translate_config_views' => array(
      t('Views'),
      t('Include translation of all translatable strings within views.  This will not generally include translation of all results generated by each view, which is usually configurable by selecting localizable fields within the view itself.  Note: You must have the <a href="https://drupal.org/project/i18nviews" target="_blank">i18nviews</a> module enabled in order to use this.') . drupal_render($hidden_i18nviews_value),
    ),
    'lingotek_translate_config_fields' => array(
      t('Field Labels'),
      t('Include translation of all translatable field labels.  Note: You must have the <a href="https://drupal.org/project/i18n" target="_blank">i18n_field</a> sub-module enabled in order to use this.'),
    ),
    'lingotek_translate_config_builtins' => array(
      t('Built-in Interface'),
      t('When enabled, all built-in strings will be automatically translated.  (Note: this may take a while.)') . drupal_render($fr),
    ),
    'lingotek_translate_config_misc' => array(
      t('Miscellaneous Strings'),
      t('Include translation of any other miscellaneous strings found by the Internationalization (i18n) module.'),
    ),
  );
  $defaults = array();
  foreach (array_keys($options) as $config_type) {
    $defaults[$config_type] = variable_get($config_type, 0);
  }
  $form['additional_translation']['config'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#default_value' => $defaults,
  );
  $workflows = $api
    ->listWorkflows();
  if (is_array($workflows) && count($workflows) > 1) {
    $form['additional_translation']['lingotek_translate_config_options']['lingotek_translate_config_workflow_id'] = array(
      '#type' => 'select',
      '#title' => t('Workflow'),
      '#description' => t('This workflow will be used for handling these additional translation items.'),
      '#options' => $workflows,
      '#default_value' => variable_get('lingotek_translate_config_workflow_id', ''),
    );
  }
  if ($setup_complete) {
    $form['additional_translation']['lingotek_translate_config_options']['view_status'] = array(
      '#type' => 'item',
      '#description' => t('You can view the progress of the configuration translations on the <a href="@link">Translate Interface</a> page', array(
        '@link' => url('admin/config/regional/translate'),
      )),
    );
  }
  return $form;
}