Commit ea561c10 authored by alexpott's avatar alexpott

Issue #2333987 by herom: Fixed schema translation context terminology and add...

Issue #2333987 by herom: Fixed schema translation context terminology and add context for date_format configuration.
parent ee6ddbe8
......@@ -72,6 +72,7 @@ date_format:
type: string
label: 'Date format'
translatable: true
translation context: 'PHP date format'
# HTML color value.
color_hex:
......
......@@ -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;
......
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment