diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php index 8fa1ff0..69cccfd 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php @@ -90,6 +90,37 @@ function testConfigTranslation() { $this->drupalGet($langcode); $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')); + $this->assertTrue($string, 'Configuration date formats have been created upon installation.'); + + // Translate using the UI so configuration is refreshed. + $site_name = $this->randomName(20); + $search = array( + 'string' => $string->source, + 'langcode' => $langcode, + 'translation' => 'all', + ); + $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); + $textareas = $this->xpath('//textarea'); + $textarea = current($textareas); + $lid = (string) $textarea[0]['name']; + $edit = array( + $lid => 'D', + ); + $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); + + $wrapper = $this->container->get('locale.config.typed')->get('system.date_format.medium'); + + // Get translation and check we've only got the site name. + $translation = $wrapper->getTranslation($langcode); + $format = $translation->get('pattern')->get('php')->getValue(); + $this->assertEqual($format, 'D'); // , 'Got the right date format after translation.'); + + // Format 8 / 27 / 1985 @ 13:37:0 EST, it should be Tuesday. + $formatted_date = format_date(494015820, $type = 'medium', NULL, NULL, $langcode = $langcode); + $this->assertEqual($formatted_date, 'Tue'); //, 'Got the right formatted date using the date format translation.'); + // Assert strings from image module config are not available. $string = $this->storage->findString(array('source' => 'Medium (220x220)', 'context' => '', 'type' => 'configuration')); $this->assertFalse($string, 'Configuration strings have been created upon installation.'); diff --git a/core/modules/system/config/schema/system.data_types.schema.yml b/core/modules/system/config/schema/system.data_types.schema.yml index 337b14b..8688762 100644 --- a/core/modules/system/config/schema/system.data_types.schema.yml +++ b/core/modules/system/config/schema/system.data_types.schema.yml @@ -53,7 +53,7 @@ text: label: 'Text' translatable: true -# PHP Date format string that is translatable and has a specific UI +# PHP Date format string that is translatable and has a specific UI. date_format: type: string label: 'PHP date format'