Change record status: 
Project: 
Introduced in branch: 
11.4.x
Introduced in version: 
11.4.0
Description: 

The following functions are used to create a widget which could be placed on the bundle entity forms to enable content translation for those bundles, in the situation in which a language_configuration form element is not used:

  • content_translation_enable_widget()
  • content_translation_language_configuration_element_process()
  • content_translation_language_configuration_element_validate()
  • content_translation_language_configuration_element_submit()

The functions are deprecated and the functionality is converted to a new service: Drupal\content_translation\ContentTranslationEnableTranslationPerBundle

Before

class FooHooks {

  #[Hook('form_field_config_edit_form_alter')]
  public function formFieldConfigEditFormAlter(array &$form, FormStateInterface $form_state) : void {
    $form['lang'] = content_translation_enable_widget();
  }

}

After

use Drupal\content_translation\ContentTranslationEnableTranslationPerBundle;
use Drupal\Core\Hook\Attribute\Hook;

class FooHooks {

  public function __construct(
    protected ContentTranslationEnableTranslationPerBundle $contentTranslationWidget
  ) {}

  #[Hook('form_field_config_edit_form_alter')]
  public function formFieldConfigEditFormAlter(array &$form, FormStateInterface $form_state) : void {
    $form['lang'] = $this->contentTranslationWidget->getWidget('user', 'user', $form, $form_state);
  }

}
Impacts: 
Module developers
Site templates, recipes and distribution developers