Do not install language overrides for new languages during config sync

Created on 9 September 2025, 10 days ago

Problem/Motivation

When a new language is created in the user interface, \Drupal\language\Config\LanguageConfigFactoryOverride::installLanguageOverrides() is called with the language code of the newly created language so that all language overrides for that language that may be available in any shipped modules or, in particular, the install profile get installed.

If a language is being created during a config sync, this should not happen, however, because any language overrides that should end up in the target storage should be part of the sync.

But on top of just being unnecessary CPU this actually causes a problem resulting in the entire config sync failing: If a module or profile ships a language override for a config entity and that override will also be created as part of the config sync, then a

Deleted and replaced configuration entity

error will be raised.

Steps to reproduce

  1. Have a site without the German language and a with a body field on the article node type
  2. Add the German language and translate the body field (for example using Config Translation)
  3. Export the configuration and attempt to import it on another instance of the site
    You should see something like
    +-------------+----------------------------------------+-----------+
    | Collection  | Config                                 | Operation |
    +-------------+----------------------------------------+-----------+
    |             | language.entity.de                     | Create    |
    | language.de | field.field.node.article.body           | Create    |
    +-------------+----------------------------------------+-----------+
    

    as output of drush cim

You will be greeted with:

  The import failed due to the following reasons:                              
  Deleted and replaced configuration entity "field.field.node.article.body"   

Instead of the import succeeding.

Proposed resolution

Explicitly check that no config sync is happening in \Drupal\language\Entity\ConfigurableLanguage::postSave() before calling \Drupal\language\Config\LanguageConfigFactoryOverride::installLanguageOverrides().

Remaining tasks

User interface changes

-

Introduced terminology

-

API changes

-

Data model changes

-

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

language system

Created by

🇩🇪Germany tstoeckler Essen, Germany

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024