$this->language =
$language;
// ConfigTranslationFormAccess will not grant access if this raises an
// exception, so we can call this without a try-catch block here.
$langcode =
$this->mapper->
getLangcode();
$this->sourceLanguage =
$this->languageManager->
getLanguage($langcode);
// Get base language configuration to display in the form before setting the
// language to use for the form. This avoids repetitively settings and
// resetting the language to get original values later.
$this->baseConfigData =
$this->mapper->
getConfigData();
// Set the translation target language on the configuration factory.
$original_language =
$this->languageManager->
getConfigOverrideLanguage();
$this->languageManager->
setConfigOverrideLanguage($this->language
);
// Add some information to the form state for easier form altering.
$form_state->
set('config_translation_mapper',
$this->mapper
);
$form_state->
set('config_translation_language',
$this->language
);
$form_state->
set('config_translation_source_language',
$this->sourceLanguage
);
$form['#attached'
]['library'
][] = 'config_translation/drupal.config_translation.admin';