diff --git a/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php b/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php index 01ada70..5b0db2d 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php @@ -288,7 +288,7 @@ public function translateString($name, $langcode, $source, $context) { * @param string|NULL $name * Name of the original configuration. Set to NULL to get the name prefix * for all $langcode overrides. -loca * + * * @return string */ public static function localeConfigName($langcode, $name = NULL) { diff --git a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php index cef4fb1..5d6b200 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php @@ -9,14 +9,13 @@ use Drupal\Core\Language\Language; use Drupal\Core\TypedData\ContextAwareInterface; -use Drupal\Core\TypedData\TranslatableInterface; use Drupal\Core\Config\Schema\Element; use Drupal\Core\Config\Schema\ArrayElement; /** * Defines the locale configuration wrapper object. */ -class LocaleTypedConfig extends Element implements TranslatableInterface { +class LocaleTypedConfig extends Element { /** * The typed configuration data. @@ -67,28 +66,10 @@ public function getTypedConfig() { /** * {@inheritdoc} */ - public function getTranslationLanguages($include_default = TRUE) { - // Configuration may be in English (when from shipped config) even on a - // site where English is not a configured language. - $languages = locale_translatable_language_list(); - if ($include_default) { - $default = $this->language(); - $languages[$default->langcode] = $default; - } - else { - unset($languages[$this->langcode]); - } - return $languages; - } - - /** - * {@inheritdoc} - */ - public function getTranslation($langcode, $strict = TRUE) { + public function getTranslation($langcode) { $options = array( 'source' => $this->langcode, 'target' => $langcode, - 'strict' => $strict, ); $data = $this->getElementTranslation($this->getTypedConfig(), $options); return $this->localeConfig->create($this->definition, $data); @@ -98,7 +79,7 @@ public function getTranslation($langcode, $strict = TRUE) { * {@inheritdoc} */ public function language() { - return new Language(array('langcode' => $this->langcode)); + return language_load($this->langcode); } /** @@ -183,7 +164,6 @@ protected function getArrayTranslation(ArrayElement $element, array $options) { * Array with translation options that must contain the following keys: * - 'source', Source language code. * - 'target', Target language code. - * - 'strict', True to return only elements that actually have translation. * * @return bool * Whether the element fits the translation criteria. @@ -200,8 +180,8 @@ protected function translateElement(\Drupal\Core\TypedData\TypedDataInterface $e } } } - // The element does not have a translation. If strict mode we drop it. - return empty($options['strict']); + // The element does not have a translation. + return FALSE; } } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php index f4d34ac..f17404a 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php @@ -80,19 +80,11 @@ function testConfigTranslation() { $wrapper = $this->container->get('locale.config.typed')->get('system.site'); - // Get strict translation and check we've got only the site name. - $translation = $wrapper->getTranslation($langcode, TRUE); + // Get translation and check we've only got the site name. + $translation = $wrapper->getTranslation($langcode); $properties = $translation->getProperties(); - $this->assertEqual(count($properties), 1, 'Got the right number of properties with strict translation'); - $this->assertEqual($properties['name']->getValue(), $site_name, 'Got the right translation for site name with strict translation'); - - // Get non strict translation and check we got all unmodified properties. - // Although system.site contains 7 properties, the test system modified - // the site email address, so we get back 4 properties. - $translation = $wrapper->getTranslation($langcode, FALSE); - $properties = $translation->getProperties(); - $this->assertTrue(count($properties) == 4 && count($translation->get('page')) == 1, 'Got the right number of properties with non strict translation'); - $this->assertEqual($properties['name']->getValue(), $site_name, 'Got the right translation for site name with non strict translation'); + $this->assertEqual(count($properties), 1, 'Got the right number of properties after translation'); + $this->assertEqual($properties['name']->getValue(), $site_name, 'Got the right translation for site name after translation'); // Check the translated site name is displayed. $this->drupalGet($langcode); @@ -139,9 +131,9 @@ function testConfigTranslation() { // Try more complex configuration data. $wrapper = $this->container->get('locale.config.typed')->get('image.style.medium'); - $translation = $wrapper->getTranslation($langcode, TRUE); + $translation = $wrapper->getTranslation($langcode); $property = $translation->get('label'); - $this->assertEqual($property->getValue(), $image_style_label, 'Got the right translation for image style name with strict translation'); + $this->assertEqual($property->getValue(), $image_style_label, 'Got the right translation for image style name after translation'); // Quick test to ensure translation file exists. $this->assertEqual(config('locale.config.xx.image.style.medium')->get('label'), $image_style_label); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php index 3ae0ae4..0392c0f 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -295,7 +295,7 @@ function testConfigPoFile() { // Translations got recorded in the config system. foreach ($config_strings as $config_key => $config_string) { $wrapper = $locale_config->get($config_key); - $translation = $wrapper->getTranslation($langcode, TRUE); + $translation = $wrapper->getTranslation($langcode); $properties = $translation->getProperties(); $this->assertEqual(count($properties), 1, 'Got the right number of properties with strict translation'); $this->assertEqual($properties[$config_string[2]]->getValue(), $config_string[1]); diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index eb32027..5e8f7b9 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -864,7 +864,7 @@ function locale_config_update_multiple(array $names, $langcodes = array()) { foreach ($names as $name) { $wrapper = \Drupal\locale\Locale::config()->get($name); foreach ($langcodes as $langcode) { - $translation = $wrapper->getValue() ? $wrapper->getTranslation($langcode, TRUE)->getValue() : NULL; + $translation = $wrapper->getValue() ? $wrapper->getTranslation($langcode)->getValue() : NULL; if ($translation) { \Drupal\locale\Locale::config()->saveTranslationData($name, $langcode, $translation); $count++;