diff --git a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php index 14dff64..73d01df 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php @@ -7,18 +7,15 @@ namespace Drupal\locale; +use Drupal\Core\Config\Config; use Drupal\Core\Language\Language; -use Drupal\Core\Config\Metadata\TypedConfig; -use Drupal\Core\Config\Metadata\ElementInterface; use Drupal\Core\TypedData\TranslatableInterface; +use Drupal\Core\Config\Schema\Element; /** * Defines the locale configuration wrapper object. - * - * This is an extension of the base TypedConfig class that provides - * translations using the localization system. */ -class LocaleTypedConfig extends TypedConfig implements TranslatableInterface { +class LocaleTypedConfig extends Config implements TranslatableInterface { /** * The language code for which this is a translation. @@ -60,7 +57,8 @@ class LocaleTypedConfig extends TypedConfig implements TranslatableInterface { * translations. */ public function __construct($name, $data, StringStorageInterface $localeStorage = NULL) { - parent::__construct($name, $data); + $this->name = $name; + $this->data = $data; $this->localeStorage = $localeStorage; } @@ -132,6 +130,18 @@ public function getTranslation($langcode, $strict = TRUE) { } /** + * Gets the configuration language. + * + * @return \Drupal\Core\Language\Language + * The language object. + */ + public function getLanguage() { + // The default language will be English as this is hardcoded information. + $langcode = isset($this->data['langcode']) ? $this->data['langcode'] : 'en'; + return new Language(array('langcode' => $langcode)); + } + + /** * Implements Drupal\Core\TypedData\TranslatableInterface::language(). */ public function language() { @@ -159,7 +169,7 @@ protected function getTranslatedData($elements, $options) { $translation = array(); foreach ($elements as $key => $element) { $value = NULL; - if ($element instanceof ElementInterface) { + if ($element instanceof Element) { $value = $this->getTranslatedData($element, $options); } elseif ($this->translateElement($element, $options)) { @@ -196,7 +206,7 @@ public function translateElement($element, $options) { if ($this->canTranslate($options['source'], $options['target'])) { $definition = $element->getDefinition(); $value = $element->getValue(); - if ($value && is_string($value) && $element->getType() == 'text' && (!isset($definition['translatable']) || $definition['translatable'])) { + if ($value && $element->isTranslatable()) { $context = isset($definition['locale context']) ? $definition['locale context'] : ''; if ($translation = $this->translateString($options['target'], $value, $context)) { $element->setValue($translation);