public function LocaleSettingsForm::buildForm

Implements \Drupal\Core\Form\FormInterface::buildForm().

Overrides SystemConfigFormBase::buildForm

File

drupal/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php, line 26
Contains \Drupal\user\LocaleSettingsForm.

Class

LocaleSettingsForm
Configure locale settings for this site.

Namespace

Drupal\locale\Form

Code

public function buildForm(array $form, array &$form_state) {
  $config = $this->configFactory
    ->get('locale.settings');
  $form['update_interval_days'] = array(
    '#type' => 'radios',
    '#title' => t('Check for updates'),
    '#default_value' => $config
      ->get('translation.update_interval_days'),
    '#options' => array(
      '0' => t('Never (manually)'),
      '1' => t('Daily'),
      '7' => t('Weekly'),
    ),
    '#description' => t('Select how frequently you want to check for new interface translations for your currently installed modules and themes. <a href="@url">Check updates now</a>.', array(
      '@url' => url('admin/reports/translations/check'),
    )),
  );
  $form['check_disabled_modules'] = array(
    '#type' => 'checkbox',
    '#title' => t('Check for updates of disabled modules and themes'),
    '#default_value' => $config
      ->get('translation.check_disabled_modules'),
  );
  if ($directory = config('locale.settings')
    ->get('translation.path')) {
    $description = t('Translation files are stored locally in the  %path directory. You can change this directory on the <a href="@url">File system</a> configuration page.', array(
      '%path' => $directory,
      '@url' => url('admin/config/media/file-system'),
    ));
  }
  else {
    $description = t('Translation files will not be stored locally. Change the Interface translation directory on the <a href="@url">File system configuration</a> page.', array(
      '@url' => url('admin/config/media/file-system'),
    ));
  }
  $form['#translation_directory'] = $directory;
  $form['use_source'] = array(
    '#type' => 'radios',
    '#title' => t('Translation source'),
    '#default_value' => $config
      ->get('translation.use_source'),
    '#options' => array(
      LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL => t('Drupal translation server and local files'),
      LOCALE_TRANSLATION_USE_SOURCE_LOCAL => t('Local files only'),
    ),
    '#description' => t('The source of translation files for automatic interface translation.') . ' ' . $description,
  );
  if ($config
    ->get('translation.overwrite_not_customized') == FALSE) {
    $default = LOCALE_TRANSLATION_OVERWRITE_NONE;
  }
  elseif ($config
    ->get('translation.overwrite_customized') == TRUE) {
    $default = LOCALE_TRANSLATION_OVERWRITE_ALL;
  }
  else {
    $default = LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED;
  }
  $form['overwrite'] = array(
    '#type' => 'radios',
    '#title' => t('Import behaviour'),
    '#default_value' => $default,
    '#options' => array(
      LOCALE_TRANSLATION_OVERWRITE_NONE => t("Don't overwrite existing translations."),
      LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED => t('Only overwrite imported translations, customized translations are kept.'),
      LOCALE_TRANSLATION_OVERWRITE_ALL => t('Overwrite existing translations.'),
    ),
    '#description' => t('How to treat existing translations when automatically updating the interface translations.'),
  );
  return parent::buildForm($form, $form_state);
}