Problem/Motivation

Consider a module that ships display_label: Default in its default configuration and declares translatable: 'false' on display_label in its schema.

On a site whose default language is German, Locale adds langcode: de and, if a German translation of Default already exists in the same context, can overwrite the active setting with Standard.

Correcting the schema to translatable: false later leaves the overwritten value and any existing language overrides in place.

The three methods that read translatable disagree on what 'false' means:

  • LocaleConfigManager::getTranslatableData() and ConfigMapperManager::findTranslatable() both treat the non-empty string 'false' as true, so Locale includes the setting in translation updates and Configuration Translation reports it as translatable.
  • ArrayElement::hasTranslatableElements() checks for TRUE strictly and therefore does not count display_label as translatable.

Steps to reproduce

  1. In a test module, ship display_label: Default in config/install/example.settings.yml. In the schema for example.settings, define display_label as a string with translatable: 'false'.
  2. On a site with German as its default language, enable Locale and Configuration Translation. Ensure that Default already has the German translation Standard in the same context.
  3. Install the test module. After Locale updates configuration translations, check the active configuration for example.settings. It contains display_label: Standard.
  4. Call ConfigMapperManager::hasTranslatable() for example.settings. It returns TRUE. Call ArrayElement::hasTranslatableElements() on the same typed configuration object. It returns FALSE.
  5. Change the schema flag to unquoted false, rebuild caches and run the translation update again. The active value remains Standard.

Proposed resolution

Use BooleanInput::parse() from #3644386: "false" is interpreted as TRUE in boolean configuration when the resolved schema definition contains a translatable flag, including one inherited from a schema type.

  • All three readers should interpret 'false' as FALSE and report a deprecation identifying the schema property.
  • If the flag is absent, retain the existing default without a deprecation.
  • For unrecognized input, report a deprecation and preserve each reader's existing fallback during the deprecation period.

Add kernel coverage for all three readers, including a schema definition altered by a module. Verify that LocaleConfigManager::updateConfigTranslations() leaves the active value intact and creates no language override for a property marked translatable: 'false'.

Remaining tasks

Postponed on #3644386: "false" is interpreted as TRUE in boolean configuration.

User interface changes

None.

Introduced terminology

None.

API changes

The translatable schema flag now follows the boolean input rules from #3644386: "false" is interpreted as TRUE in boolean configuration:

  • Use unquoted true or false in config schema YAML files and native booleans in PHP.
  • Of the non-boolean values, only 0, 1, '0' and '1' are accepted without a deprecation.

ConfigMapperManager::hasTranslatable() and LocaleConfigManager::getTranslatableDefaultConfig() now treat translatable: 'false' as FALSE.

ArrayElement::hasTranslatableElements() now also counts a property marked translatable: 1 or translatable: '1' as translatable.

Data model changes

None.

Release notes snippet

All three readers of the translatable schema flag now interpret recognized boolean strings consistently, including 'false', 'true', '0' and '1'.

Issue fork drupal-3644401

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pancho created an issue.