You are here

public static function LingotekLanguageForm::validateLocale in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()
  2. 4.0.x src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()
  3. 3.0.x src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()
  4. 3.1.x src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()
  5. 3.2.x src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()
  6. 3.3.x src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()
  7. 3.4.x src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()
  8. 3.5.x src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()
  9. 3.6.x src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()
  10. 3.7.x src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()
  11. 3.8.x src/Form/LingotekLanguageForm.php \Drupal\lingotek\Form\LingotekLanguageForm::validateLocale()

Validate the configurable language type form with lingotek options.

Parameters

array $form: The form definition array for the configurable language entity.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

See also

lingotek_form_language_admin_add_form_alter()

lingotek_form_language_admin_edit_form_alter()

File

src/Form/LingotekLanguageForm.php, line 113

Class

LingotekLanguageForm
Alters the Drupal language module language forms.

Namespace

Drupal\lingotek\Form

Code

public static function validateLocale(&$form, FormStateInterface $form_state) {
  $form_key = [
    'lingotek_locale',
  ];
  if (!$form_state
    ->isValueEmpty($form_key)) {
    $value = $form_state
      ->getValue($form_key);
    if (!self::isValidLocale($value)) {
      $form_state
        ->setErrorByName('lingotek_locale', t('The Lingotek locale %locale does not exist.', [
        '%locale' => $value,
      ]));
    }
  }
}