API to disable bundle translation in one operation

Created on 12 December 2023, 11 months ago

Problem/Motivation

Usually, language configuration is saved through the form at admin/config/regional/content-language, that includes options for each translatable entity bundle.

From there Drupal\language\Form\ContentLanguageSettingsForm submit handler is called, and a save over the related Drupal\language\Entity\ContentLanguageSettings object is performed.

In the context of 📌 Use the API to set up languages in tests that are not specifically testing the language form Fixed , a new trait is added to help with the specific action of disabling translation for a given bundle.

In that trait, the action of saving the related ContentLanguageSettings seems to not be enough to effectively disable a given bundle translation.
Instead it is also needed to delete that configuration entity.

Steps to reproduce

In a code snippet:

<?php
// 1. The following two statements are not enough to disable it.
$content_language_settings = ContentLanguageSettings::loadByEntityTypeBundle($entity_type_id, $bundle);
$content_language_settings->setLanguageAlterable(FALSE)
  ->save();
// 2. Instead, deleting the configuration entity is also needed.
$content_language_settings->delete();

Proposed resolution

Suggestions are welcome.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Active

Version

11.0 🔥

Component
Language system 

Last updated about 12 hours ago

  • Maintained by
  • 🇩🇪Germany @sun
Created by

🇵🇪Peru marvil07

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024