getStandardLanguageListWithoutConfigured example

public function getFormId() {
    // @todo Remove in favor of base method.     return 'language_admin_add_form';
  }

  /** * {@inheritdoc} */
  public function form(array $form, FormStateInterface $form_state) {
    $form['#title'] = $this->t('Add language');

    $predefined_languages = $this->languageManager->getStandardLanguageListWithoutConfigured();

    $predefined_languages['custom'] = $this->t('Custom language...');
    $predefined_default = $form_state->getValue('predefined_langcode', key($predefined_languages));
    $form['predefined_langcode'] = [
      '#type' => 'select',
      '#title' => $this->t('Language name'),
      '#default_value' => $predefined_default,
      '#options' => $predefined_languages,
    ];
    $form['predefined_submit'] = [
      '#type' => 'submit',
      
    $languages = $this->languageManager->getLanguages();

    $existing_languages = [];
    foreach ($languages as $langcode => $language) {
      $existing_languages[$langcode] = $language->getName();
    }

    // If we have no languages available, present the list of predefined languages     // only. If we do have already added languages, set up two option groups with     // the list of existing and then predefined languages.     if (empty($existing_languages)) {
      $language_options = $this->languageManager->getStandardLanguageListWithoutConfigured();
    }
    else {
      $language_options = [
        (string) $this->t('Existing languages') => $existing_languages,
        (string) $this->t('Languages not yet added') => $this->languageManager->getStandardLanguageListWithoutConfigured(),
      ];
    }

    $form['mappings'] = [
      '#type' => 'table',
      '#header' => [
        
    $existing_languages = [];
    foreach ($languages as $langcode => $language) {
      if (locale_is_translatable($langcode)) {
        $existing_languages[$langcode] = $language->getName();
      }
    }

    // If we have no languages available, present the list of predefined     // languages only. If we do have already added languages, set up two option     // groups with the list of existing and then predefined languages.     if (empty($existing_languages)) {
      $language_options = $this->languageManager->getStandardLanguageListWithoutConfigured();
      $default = key($language_options);
    }
    else {
      $default = key($existing_languages);
      $language_options = [
        (string) $this->t('Existing languages') => $existing_languages,
        (string) $this->t('Languages not yet added') => $this->languageManager->getStandardLanguageListWithoutConfigured(),
      ];
    }

    $validators = [
      
Home | Imprint | This part of the site doesn't use cookies.