diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index ea67e43..60628fb 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -72,6 +72,7 @@ date_format: type: string label: 'Date format' translatable: true + translation context: 'PHP date format' # HTML color value. color_hex: diff --git a/core/modules/locale/src/LocaleTypedConfig.php b/core/modules/locale/src/LocaleTypedConfig.php index cbe9d1a..ab373fe 100644 --- a/core/modules/locale/src/LocaleTypedConfig.php +++ b/core/modules/locale/src/LocaleTypedConfig.php @@ -167,7 +167,7 @@ protected function getArrayTranslation(ArrayElement $element, array $options) { * Translatable elements may use these additional keys in their data * definition: * - 'translatable', FALSE to opt out of translation. - * - 'locale context', to define the string context. + * - 'translation context', to define the string context. * * @param \Drupal\Core\TypedData\TypedDataInterface $element * Configuration element. @@ -184,7 +184,7 @@ protected function translateElement(\Drupal\Core\TypedData\TypedDataInterface $e $definition = $element->getDataDefinition(); $value = $element->getValue(); if ($value && !empty($definition['translatable'])) { - $context = isset($definition['locale context']) ? $definition['locale context'] : ''; + $context = isset($definition['translation context']) ? $definition['translation context'] : ''; if ($translation = $this->localeConfig->translateString($this->name, $options['target'], $value, $context)) { $element->setValue($translation); return TRUE; diff --git a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php index ac6bb2d..a28f996 100644 --- a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php @@ -92,7 +92,7 @@ public function testConfigTranslation() { $this->assertText($site_name, 'The translated site name is displayed after translations refreshed.'); // Check default medium date format exists and create a translation for it. - $string = $this->storage->findString(array('source' => 'D, m/d/Y - H:i', 'context' => '', 'type' => 'configuration')); + $string = $this->storage->findString(array('source' => 'D, m/d/Y - H:i', 'context' => 'PHP date format', 'type' => 'configuration')); $this->assertTrue($string, 'Configuration date formats have been created upon installation.'); // Translate using the UI so configuration is refreshed.