diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index e64bfca..0681f56 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1426,7 +1426,7 @@ function drupal_unpack($obj, $field = 'data') { * available to code that needs localization. See st() and get_t() for * alternatives. * - * @param $string + * @param $input * A string containing the English string to translate. * @param $args * An associative array of replacements to make after translation. Based @@ -1447,13 +1447,24 @@ function drupal_unpack($obj, $field = 'data') { * @see format_string() * @ingroup sanitization */ -function t($string, array $args = array(), array $options = array()) { +function t($input, array $args = array(), array $options = array()) { static $custom_strings; // Merge in default. if (empty($options['langcode'])) { $options['langcode'] = drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode; } + if (is_array($input)) { + if (isset($input[$options['langcode']])) { + return $input[$options['langcode']]; + } + elseif (isset($input['_default'])) { + return $input[$input['_default']]; + } + else { + return $input['en']; + } + } if (empty($options['context'])) { $options['context'] = ''; } @@ -1466,18 +1477,18 @@ function t($string, array $args = array(), array $options = array()) { $custom_strings[$options['langcode']] = variable_get('locale_custom_strings_' . $options['langcode'], array()); } // Custom strings work for English too, even if locale module is disabled. - if (isset($custom_strings[$options['langcode']][$options['context']][$string])) { - $string = $custom_strings[$options['langcode']][$options['context']][$string]; + if (isset($custom_strings[$options['langcode']][$options['context']][$input])) { + $input = $custom_strings[$options['langcode']][$options['context']][$input]; } // Translate with locale module if enabled. elseif ($options['langcode'] != LANGUAGE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('locale')) { - $string = locale($string, $options['context'], $options['langcode']); + $input = locale($input, $options['context'], $options['langcode']); } if (empty($args)) { - return $string; + return $input; } else { - return format_string($string, $args); + return format_string($input, $args); } } diff --git a/core/lib/Drupal/Core/Config/DrupalConfig.php b/core/lib/Drupal/Core/Config/DrupalConfig.php index f5a9220..9eb90d4 100644 --- a/core/lib/Drupal/Core/Config/DrupalConfig.php +++ b/core/lib/Drupal/Core/Config/DrupalConfig.php @@ -132,18 +132,25 @@ class DrupalConfig { * @param $value * @todo */ - public function set($key, $value) { + public function set($key, $value, $subkey = '') { // Type-cast value into a string. $value = $this->castValue($value); // The dot/period is a reserved character; it may appear between keys, but // not within keys. + $ref = &$this->data; + if ($subkey) { + if (empty($this->data['_default'])) { + $this->data['_default'] = $subkey; + } + $ref = &$ref[$subkey]; + } $parts = explode('.', $key); if (count($parts) == 1) { - $this->data[$key] = $value; + $ref[$key] = $value; } else { - drupal_array_set_nested_value($this->data, $parts, $value); + drupal_array_set_nested_value($ref, $parts, $value); } return $this; }