$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' =>
[