diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index 93743e4..9314121 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -421,9 +421,17 @@ core.date_format.*: type: boolean label: 'Locked' pattern: - type: date_format + type: core_date_format_pattern.[%parent.locked] label: 'PHP date format' +core_date_format_pattern.0: + type: date_format + label: 'Date format' + +core_date_format_pattern.1: + type: string + label: 'Date format' + # Generic field settings schemas. field.storage_settings.*: diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index 6bd33cc..db08753 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -283,8 +283,12 @@ protected function replaceVariable($value, $data) { return $value; } elseif (!$parts) { + $value = $data[$name]; + if (is_bool($value)) { + $value = (int) $value; + } // If no more parts left, this is the final property. - return (string)$data[$name]; + return (string) $value; } else { // Get nested value and continue processing. diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationDateFormatUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationDateFormatUiTest.php new file mode 100644 index 0000000..7f68682 --- /dev/null +++ b/core/modules/config_translation/src/Tests/ConfigTranslationDateFormatUiTest.php @@ -0,0 +1,63 @@ +save(); + } + + $user = $this->drupalCreateUser(array( + 'administer site configuration', + 'translate configuration', + )); + $this->drupalLogin($user); + } + + /** + * Tests date format translation behaviour. + */ + public function testDateFormatUI() { + $this->drupalGet('admin/config/regional/date-time'); + + // Assert translation link unlocked date format. + $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/medium/translate'); + + // Assert translation link locked date format. + $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_datetime/translate'); + + // Date pattern is visible on unlocked date formats. + $this->drupalGet('admin/config/regional/date-time/formats/manage/medium/translate/de/add'); + $this->assertField('translation[config_names][core.date_format.medium][pattern]'); + + // Date pattern is not visible on locked date formats. + $this->drupalGet('admin/config/regional/date-time/formats/manage/html_datetime/translate/es/add'); + $this->assertNoField('translation[config_names][core.date_format.html_datetime][pattern]'); + } + +}