diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 667c3ab..b85feaf 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2396,7 +2396,7 @@ function drupal_installation_attempted() { function drupal_language_initialize() { $language_manager = Drupal::languageManager(); $language_manager->init(); - Drupal::translation()->setDefaultLangcode($language_manager->getLanguage(Language::TYPE_INTERFACE)->langcode); + Drupal::translation()->setDefaultLangcode($language_manager->getLanguage(Language::TYPE_INTERFACE)->id); } /** @@ -2476,30 +2476,26 @@ function language_list($flags = Language::STATE_CONFIGURABLE) { // Fill in master language list based on current configuration. $default = language_default(); if (language_multilingual() || module_exists('language')) { - // Use language module configuration if available. We can not use - // entity_load_multiple() because this breaks during updates. - // @todo Use entity_load_by_properties() https://drupal.org/node/2026227 - $language_entities = config_get_storage_names_with_prefix('language.entity'); + // Use language module configuration if available. + $language_entities = entity_load_multiple('language_entity'); // Initialize default property so callers have an easy reference and can // save the same object without data loss. - foreach ($language_entities as $langcode_config_name) { - $langcode = substr($langcode_config_name, strlen('language.entity.')); - $info = config($langcode_config_name)->get(); + foreach ($language_entities as $langcode => $lang) { $languages[$langcode] = new Language(array( - 'default' => ($info['id'] == $default->langcode), - 'name' => $info['label'], - 'langcode' => $info['id'], - 'direction' => $info['direction'], - 'locked' => $info['locked'], - 'weight' => $info['weight'], + 'default' => $lang->id == $default->id, + 'name' => $lang->label, + 'id' => $lang->id, + 'direction' => $lang->direction, + 'locked' => $lang->locked, + 'weight' => $lang->weight, )); } Language::sort($languages); } else { // No language module, so use the default language only. - $languages = array($default->langcode => $default); + $languages = array($default->id => $default); // Add the special languages, they will be filtered later if needed. $languages += language_default_locked_languages($default->weight); } @@ -2547,12 +2543,12 @@ function language_default_locked_languages($weight = 0) { $languages = array(); $languages[Language::LANGCODE_NOT_SPECIFIED] = new Language(array( - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'id' => Language::LANGCODE_NOT_SPECIFIED, 'name' => t('Not specified'), 'weight' => ++$weight, ) + $locked_language); $languages[Language::LANGCODE_NOT_APPLICABLE] = new Language(array( - 'langcode' => Language::LANGCODE_NOT_APPLICABLE, + 'id' => Language::LANGCODE_NOT_APPLICABLE, 'name' => t('Not applicable'), 'weight' => ++$weight, ) + $locked_language); @@ -2618,6 +2614,7 @@ function language_is_locked($langcode) { */ function language_default() { $info = variable_get('language_default', array( + 'id' => 'en', 'langcode' => 'en', 'name' => 'English', 'direction' => 0, diff --git a/core/includes/common.inc b/core/includes/common.inc index 61b63be..b018fe9 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -903,7 +903,7 @@ function filter_xss_bad_protocol($string) { * Arbitrary elements may be added using the $args associative array. */ function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) { - $langcode = $langcode ? $langcode : language(Language::TYPE_CONTENT)->langcode; + $langcode = $langcode ? $langcode : language(Language::TYPE_CONTENT)->id; $output = "\n"; $output .= ' ' . check_plain($title) . "\n"; @@ -1416,7 +1416,7 @@ function l($text, $path, array $options = array()) { $active = array( 'path' => current_path(), 'front_page' => drupal_is_front_page(), - 'language' => language(Language::TYPE_URL)->langcode, + 'language' => language(Language::TYPE_URL)->id, 'query' => Drupal::service('request')->query->all(), ); } @@ -1427,7 +1427,7 @@ function l($text, $path, array $options = array()) { // An active link's path is equal to the current path. $variables['url_is_active'] = ($path == $active['path'] || ($path == '' && $active['front_page'])) // The language of an active link is equal to the current language. - && (empty($variables['options']['language']) || $variables['options']['language']->langcode == $active['language']) + && (empty($variables['options']['language']) || $variables['options']['language']->id == $active['language']) // The query parameters of an active link are equal to the current parameters. && ($variables['options']['query'] == $active['query']); @@ -5037,7 +5037,7 @@ function drupal_render_cid_parts($granularity = NULL) { // part. if (language_multilingual()) { foreach (language_types_get_configurable() as $language_type) { - $cid_parts[] = language($language_type)->langcode; + $cid_parts[] = language($language_type)->id; } } diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 743cc4a..f432977 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -60,7 +60,7 @@ function entity_info_cache_clear() { function entity_get_bundles($entity_type = NULL) { $bundles = &drupal_static(__FUNCTION__); if (!$bundles) { - $langcode = language(Language::TYPE_INTERFACE)->langcode; + $langcode = language(Language::TYPE_INTERFACE)->id; if ($cache = cache()->get("entity_bundle_info:$langcode")) { $bundles = $cache->data; } @@ -118,7 +118,7 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N function entity_get_view_modes($entity_type = NULL) { $view_modes = &drupal_static(__FUNCTION__); if (!$view_modes) { - $langcode = language(Language::TYPE_INTERFACE)->langcode; + $langcode = language(Language::TYPE_INTERFACE)->id; if ($cache = cache()->get("entity_view_mode_info:$langcode")) { $view_modes = $cache->data; } diff --git a/core/includes/form.inc b/core/includes/form.inc index 4689711..abad44e 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -3854,7 +3854,7 @@ function form_process_machine_name($element, &$form_state) { 'machineName' => array( '#' . $source['#id'] => $element['#machine_name'], ), - 'langcode' => $language->langcode, + 'langcode' => $language->id, ), ); $element['#attached']['library'][] = array('system', 'drupal.machine-name'); diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 1ecd819..aa11240 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -298,7 +298,7 @@ function install_begin_request(&$install_state) { // (eg. pre-database data screens we are unable to persistently store // the default language), we should set language_default so the proper // language is used to display installer pages as early as possible. - if (!empty($install_state['parameters']['langcode']) && language_default()->langcode != $install_state['parameters']['langcode']) { + if (!empty($install_state['parameters']['langcode']) && language_default()->id != $install_state['parameters']['langcode']) { $GLOBALS['conf']['language_default'] = array('langcode' => $install_state['parameters']['langcode']); } @@ -1547,7 +1547,7 @@ function install_select_language_form($form, &$form_state, $files = array()) { foreach ($files as $langcode => $uri) { $select_options[$langcode] = isset($standard_languages[$langcode]) ? $standard_languages[$langcode][1] : $langcode; $browser_options[$langcode] = new Language(array( - 'langcode' => $langcode, + 'id' => $langcode, )); } } @@ -1556,7 +1556,7 @@ function install_select_language_form($form, &$form_state, $files = array()) { foreach ($standard_languages as $langcode => $language_names) { $select_options[$langcode] = $language_names[1]; $browser_options[$langcode] = new Language(array( - 'langcode' => $langcode, + 'id' => $langcode, )); } } @@ -1819,7 +1819,7 @@ function install_import_translations(&$install_state) { // Drupal does not know about this language, so we prefill its values with // our best guess. The user will be able to edit afterwards. $language = new Language(array( - 'langcode' => $langcode, + 'id' => $langcode, 'name' => $langcode, 'default' => TRUE, )); @@ -1828,7 +1828,7 @@ function install_import_translations(&$install_state) { else { // A known predefined language, details will be filled in properly. $language = new Language(array( - 'langcode' => $langcode, + 'id' => $langcode, 'default' => TRUE, )); language_save($language); @@ -2497,7 +2497,7 @@ function install_configure_form_submit($form, &$form_state) { config('system.site') ->set('name', $form_state['values']['site_name']) ->set('mail', $form_state['values']['site_mail']) - ->set('langcode', language_default()->langcode) + ->set('langcode', language_default()->id) ->save(); config('system.timezone') diff --git a/core/includes/language.inc b/core/includes/language.inc index 896cf69..976dd75 100644 --- a/core/includes/language.inc +++ b/core/includes/language.inc @@ -92,7 +92,7 @@ * * // If we are on an administrative path, override with the default language. * if (isset($_GET['q']) && strtok($_GET['q'], '/') == 'admin') { - * return language_default()->langcode; + * return language_default()->id; * } * return $langcode; * } @@ -409,7 +409,7 @@ function language_negotiation_info() { $languages = language_list(); $selected_language = $languages[language_from_selected($languages)]; $description = 'Language based on a selected language. '; - $description .= ($selected_language->langcode == language_default()->langcode) ? "(Site's default language (@language_name))" : '(@language_name)'; + $description .= ($selected_language->id == language_default()->id) ? "(Site's default language (@language_name))" : '(@language_name)'; // Add the default language negotiation method. $negotiation_info[LANGUAGE_NEGOTIATION_SELECTED] = array( 'callbacks' => array( @@ -488,9 +488,9 @@ function language_from_selected($languages) { $langcode = (string) config('language.negotiation')->get('selected_langcode'); // Replace the site's default langcode by its real value. if ($langcode == 'site_default') { - $langcode = language_default()->langcode; + $langcode = language_default()->id; } - return isset($languages[$langcode]) ? $langcode : language_default()->langcode; + return isset($languages[$langcode]) ? $langcode : language_default()->id; } /** @@ -517,7 +517,7 @@ function language_url_split_prefix($path, $languages) { // Search prefix within enabled languages. $prefixes = language_negotiation_url_prefixes(); foreach ($languages as $language) { - if (isset($prefixes[$language->langcode]) && $prefixes[$language->langcode] == $prefix) { + if (isset($prefixes[$language->id]) && $prefixes[$language->id] == $prefix) { // Rebuild $path with the language removed. return array($language, implode('/', $args)); } diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 66d1e2a..2cb0e80 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1161,7 +1161,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) { // Use $mlid as a flag for whether the data being loaded is for the whole tree. $mlid = isset($link['mlid']) ? $link['mlid'] : 0; // Generate a cache ID (cid) specific for this $menu_name, $link, $language, and depth. - $cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $language_interface->langcode . ':' . (int) $max_depth; + $cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $language_interface->id . ':' . (int) $max_depth; if (!isset($tree[$cid])) { // If the static variable doesn't have the data, check {cache_menu}. @@ -1277,7 +1277,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = $max_depth = min($max_depth, MENU_MAX_DEPTH); } // Generate a cache ID (cid) specific for this page. - $cid = 'links:' . $menu_name . ':page:' . $item['href'] . ':' . $language_interface->langcode . ':' . (int) $item['access'] . ':' . (int) $max_depth; + $cid = 'links:' . $menu_name . ':page:' . $item['href'] . ':' . $language_interface->id . ':' . (int) $item['access'] . ':' . (int) $max_depth; // If we are asked for the active trail only, and $menu_name has not been // built and cached for this page yet, then this likely means that it // won't be built anymore, as this function is invoked from @@ -1425,7 +1425,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) { if (isset($parameters['expanded'])) { sort($parameters['expanded']); } - $tree_cid = 'links:' . $menu_name . ':tree-data:' . $language_interface->langcode . ':' . hash('sha256', serialize($parameters)); + $tree_cid = 'links:' . $menu_name . ':tree-data:' . $language_interface->id . ':' . hash('sha256', serialize($parameters)); // If we do not have this tree in the static cache, check {cache_menu}. if (!isset($trees[$tree_cid])) { diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 45737c5..19a2824 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1731,7 +1731,7 @@ function theme_links($variables) { // Handle links. if (isset($link['href'])) { $is_current_path = ($link['href'] == current_path() || ($link['href'] == '' && drupal_is_front_page())); - $is_current_language = (empty($link['language']) || $link['language']->langcode == $language_url->langcode); + $is_current_language = (empty($link['language']) || $link['language']->id == $language_url->id); if ($is_current_path && $is_current_language) { $class[] = 'active'; } @@ -2633,7 +2633,7 @@ function template_preprocess_html(&$variables) { $variables['html_attributes'] = new Attribute; // HTML element attributes. - $variables['html_attributes']['lang'] = $language_interface->langcode; + $variables['html_attributes']['lang'] = $language_interface->id; $variables['html_attributes']['dir'] = $language_interface->direction ? 'rtl' : 'ltr'; // Add favicon. diff --git a/core/includes/update.inc b/core/includes/update.inc index 3659caf..85f5446 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -320,9 +320,9 @@ function update_prepare_d8_bootstrap() { // triggers a call into system_stream_wrappers(), which calls t(), which // calls into language_default(). $language_default = variable_get('language_default'); - if (!empty($language_default) && (isset($language_default->langcode) || isset($language_default->language))) { - if (!isset($language_default->langcode)) { - $language_default->langcode = $language_default->language; + if (!empty($language_default) && (isset($language_default->id) || isset($language_default->language))) { + if (!isset($language_default->id)) { + $language_default->id = $language_default->language; } unset($language_default->language); // In D8, the 'language_default' is not anymore an object, but an array, @@ -535,7 +535,7 @@ function update_prepare_d8_language() { foreach ($languages as $language) { db_insert('language') ->fields(array( - 'langcode' => $language->langcode, + 'langcode' => $language->id, 'name' => $language->name, 'weight' => $language->weight, // These languages are locked, default to enabled. @@ -549,7 +549,7 @@ function update_prepare_d8_language() { $language_default = variable_get('language_default'); if (!empty($language_default)) { if (isset($language_default->language)) { - $language_default->langcode = $language_default->language; + $language_default->id = $language_default->language; unset($language_default->language); } unset($language_default->enabled); @@ -1573,3 +1573,79 @@ function update_replace_permissions($replace) { ->save(); } } + +/** + * Returns a list of languages set up on the site during upgrades. + * + * @param $flags + * (optional) Specifies the state of the languages that have to be returned. + * It can be: Language::STATE_CONFIGURABLE, Language::STATE_LOCKED, + * Language::STATE_ALL. + * + * @return array + * An associative array of languages, keyed by the language code, ordered by + * weight ascending and name ascending. + */ +function update_language_list($flags = Language::STATE_CONFIGURABLE) { + + $languages = &drupal_static(__FUNCTION__); + + // Initialize master language list. + if (!isset($languages)) { + // Initialize local language list cache. + $languages = array(); + + // Fill in master language list based on current configuration. + $default = language_default(); + if (language_multilingual() || module_exists('language')) { + // Use language module configuration if available. We can not use + // entity_load_multiple() because this breaks during updates. + // @todo Use entity_load_by_properties() https://drupal.org/node/2026227 + $language_entities = config_get_storage_names_with_prefix('language.entity'); + + // Initialize default property so callers have an easy reference and can + // save the same object without data loss. + foreach ($language_entities as $langcode_config_name) { + $langcode = substr($langcode_config_name, strlen('language.entity.')); + $info = config($langcode_config_name)->get(); + $languages[$langcode] = new Language(array( + 'default' => ($info['id'] == $default->id), + 'name' => $info['label'], + 'langcode' => $info['id'], + 'direction' => $info['direction'], + 'locked' => $info['locked'], + 'weight' => $info['weight'], + )); + } + Language::sort($languages); + } + else { + // No language module, so use the default language only. + $languages = array($default->id => $default); + // Add the special languages, they will be filtered later if needed. + $languages += language_default_locked_languages($default->weight); + } + } + + // Filter the full list of languages based on the value of the $all flag. By + // default we remove the locked languages, but the caller may request for + // those languages to be added as well. + $filtered_languages = array(); + + // Add the site's default language if flagged as allowed value. + if ($flags & Language::STATE_SITE_DEFAULT) { + $default = isset($default) ? $default : language_default(); + // Rename the default language. + $default->name = t("Site's default language (@lang_name)", array('@lang_name' => $default->name)); + $filtered_languages['site_default'] = $default; + } + + foreach ($languages as $langcode => $language) { + if (($language->locked && !($flags & Language::STATE_LOCKED)) || (!$language->locked && !($flags & Language::STATE_CONFIGURABLE))) { + continue; + } + $filtered_languages[$langcode] = $language; + } + + return $filtered_languages; +} \ No newline at end of file diff --git a/core/lib/Drupal/Component/Datetime/DateTimePlus.php b/core/lib/Drupal/Component/Datetime/DateTimePlus.php index b00124b..871aba7 100644 --- a/core/lib/Drupal/Component/Datetime/DateTimePlus.php +++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php @@ -146,7 +146,7 @@ public function __construct($time = 'now', $timezone = NULL, $format = NULL, $se // Unpack settings. $this->validateFormat = !empty($settings['validate_format']) ? $settings['validate_format'] : TRUE; - $this->langcode = !empty($settings['langcode']) ? $settings['langcode'] : NULL; + $this->id = !empty($settings['langcode']) ? $settings['langcode'] : NULL; $this->country = !empty($settings['country']) ? $settings['country'] : NULL; $this->calendar = !empty($settings['calendar']) ? $settings['calendar'] : static::CALENDAR; @@ -651,7 +651,7 @@ public static function datePad($value, $size = 2) { * TRUE if IntlDateFormatter can be used. */ public function canUseIntl($calendar = NULL, $langcode = NULL, $country = NULL) { - $langcode = !empty($langcode) ? $langcode : $this->langcode; + $langcode = !empty($langcode) ? $langcode : $this->id; $country = !empty($country) ? $country : $this->country; $calendar = !empty($calendar) ? $calendar : $this->calendar; @@ -704,7 +704,7 @@ public function format($format, $settings = array()) { } $format_string_type = isset($settings['format_string_type']) ? $settings['format_string_type'] : static::PHP; - $langcode = !empty($settings['langcode']) ? $settings['langcode'] : $this->langcode; + $langcode = !empty($settings['langcode']) ? $settings['langcode'] : $this->id; $country = !empty($settings['country']) ? $settings['country'] : $this->country; $calendar = !empty($settings['calendar']) ? $settings['calendar'] : $this->calendar; diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index 96a4dba..d560a34 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -281,7 +281,7 @@ public function create(array $values) { $class::preCreate($this, $values); // Set default language to site default if not provided. - $values += array('langcode' => language_default()->langcode); + $values += array('langcode' => language_default()->id); $entity = new $class($values, $this->entityType); // Mark this entity as new, so isNew() returns TRUE. This does not check diff --git a/core/lib/Drupal/Core/Datetime/Date.php b/core/lib/Drupal/Core/Datetime/Date.php index 93fd00f..45aa3be 100644 --- a/core/lib/Drupal/Core/Datetime/Date.php +++ b/core/lib/Drupal/Core/Datetime/Date.php @@ -93,7 +93,7 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N } if (empty($langcode)) { - $langcode = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->langcode; + $langcode = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id; } // Create a DrupalDateTime object from the timestamp and timezone. diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php index 0179bcc..7b4867c 100644 --- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php @@ -60,7 +60,7 @@ class DrupalDateTime extends DateTimePlus { public function __construct($time = 'now', $timezone = NULL, $format = NULL, $settings = array()) { // We can set the langcode and country using Drupal values. - $settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : language(Language::TYPE_INTERFACE)->langcode; + $settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : language(Language::TYPE_INTERFACE)->id; $settings['country'] = !empty($settings['country']) ? $settings['country'] : config('system.date')->get('country.default'); // Instantiate the parent class. @@ -125,7 +125,7 @@ public function format($format, $settings = array()) { $format_string_type = isset($settings['format_string_type']) ? $settings['format_string_type'] : static::PHP; $settings['calendar'] = !empty($settings['calendar']) ? $settings['calendar'] : $this->calendar; - $settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : $this->langcode; + $settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : $this->id; $settings['country'] = !empty($settings['country']) ? $settings['country'] : $this->country; // Format the date and catch errors. diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 8af2040..54051a6 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -287,7 +287,7 @@ public function language() { $language = language_load($this->langcode); if (!$language) { // Make sure we return a proper language object. - $language = new Language(array('langcode' => Language::LANGCODE_NOT_SPECIFIED)); + $language = new Language(array('id' => Language::LANGCODE_NOT_SPECIFIED)); } return $language; } @@ -318,7 +318,7 @@ public function getTranslationLanguages($include_default = TRUE) { // @todo: Replace by EntityNG implementation once all entity types have been // converted to use the entity field API. $default_language = $this->language(); - $languages = array($default_language->langcode => $default_language); + $languages = array($default_language->id => $default_language); $entity_info = $this->entityInfo(); if ($entity_info['fieldable']) { @@ -336,7 +336,7 @@ public function getTranslationLanguages($include_default = TRUE) { } if (empty($include_default)) { - unset($languages[$default_language->langcode]); + unset($languages[$default_language->id]); } return $languages; diff --git a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php index 448d434..e51f121 100644 --- a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php +++ b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php @@ -138,7 +138,7 @@ public function &__get($name) { // Language::LANGCODE_DEFAULT. This is necessary as EntityNG always keys // default language values with Language::LANGCODE_DEFAULT while field API // expects them to be keyed by langcode. - $langcode = $this->decorated->language()->langcode; + $langcode = $this->decorated->language()->id; if ($langcode != Language::LANGCODE_DEFAULT && isset($this->decorated->values[$name]) && is_array($this->decorated->values[$name])) { if (isset($this->decorated->values[$name][Language::LANGCODE_DEFAULT]) && !isset($this->decorated->values[$name][$langcode])) { $this->decorated->values[$name][$langcode] = &$this->decorated->values[$name][Language::LANGCODE_DEFAULT]; @@ -172,7 +172,7 @@ public function __set($name, $value) { // with Language::LANGCODE_DEFAULT while field API expects them to be // keyed by langcode. foreach ($value as $langcode => $data) { - if ($langcode != Language::LANGCODE_DEFAULT && $langcode == $this->decorated->language()->langcode) { + if ($langcode != Language::LANGCODE_DEFAULT && $langcode == $this->decorated->language()->id) { $value[Language::LANGCODE_DEFAULT] = $data; unset($value[$langcode]); } diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 4c3e113..c2383ce 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -163,7 +163,7 @@ public function form(array $form, array &$form_state) { // new entities. $form['langcode'] = array( '#type' => 'value', - '#value' => !$entity->isNew() ? $entity->langcode : language_default()->langcode, + '#value' => !$entity->isNew() ? $entity->id : language_default()->id, ); } return $form; @@ -241,7 +241,7 @@ protected function actions(array $form, array &$form_state) { */ public function validate(array $form, array &$form_state) { $entity = $this->buildEntity($form, $form_state); - $entity_langcode = $entity->language()->langcode; + $entity_langcode = $entity->language()->id; $violations = array(); @@ -353,7 +353,7 @@ public function getFormLangcode(array $form_state) { // If no form langcode was provided we default to the current content // language and inspect existing translations to find a valid fallback, // if any. - $langcode = language(Language::TYPE_CONTENT)->langcode; + $langcode = language(Language::TYPE_CONTENT)->id; $fallback = language_multilingual() ? language_fallback_get_candidates() : array(); while (!empty($langcode) && !isset($translations[$langcode])) { $langcode = array_shift($fallback); @@ -362,14 +362,14 @@ public function getFormLangcode(array $form_state) { // If the site is not multilingual or no translation for the given form // language is available, fall back to the entity language. - return !empty($langcode) ? $langcode : $entity->language()->langcode; + return !empty($langcode) ? $langcode : $entity->language()->id; } /** * Implements \Drupal\Core\Entity\EntityFormControllerInterface::isDefaultFormLangcode(). */ public function isDefaultFormLangcode(array $form_state) { - return $this->getFormLangcode($form_state) == $this->entity->language()->langcode; + return $this->getFormLangcode($form_state) == $this->entity->language()->id; } /** @@ -404,7 +404,7 @@ protected function submitEntityLanguage(array $form, array &$form_state) { // entity language as the new language for fields to handle any language // change. Otherwise the current form language is the proper value, since // in this case it is not supposed to change. - $current_langcode = $entity->language()->langcode == $form_langcode ? $form_state['values']['langcode'] : $form_langcode; + $current_langcode = $entity->language()->id == $form_langcode ? $form_state['values']['langcode'] : $form_langcode; foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) { $field_name = $instance['field_name']; diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index c6561b6..b9ad4e8 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -115,7 +115,7 @@ public function __construct(\Traversable $namespaces, ContainerInterface $contai $this->discovery = new AnnotatedClassDiscovery('Core/Entity', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\EntityType'); $this->discovery = new InfoHookDecorator($this->discovery, 'entity_info'); $this->discovery = new AlterDecorator($this->discovery, 'entity_info'); - $this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->langcode, 'cache', CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); + $this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id, 'cache', CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); $this->factory = new DefaultFactory($this->discovery); $this->container = $container; @@ -370,7 +370,7 @@ public function getAdminPath($entity_type, $bundle) { public function getFieldDefinitions($entity_type, $bundle = NULL) { if (!isset($this->entityFieldInfo[$entity_type])) { // First, try to load from cache. - $cid = 'entity_field_definitions:' . $entity_type . ':' . $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->langcode; + $cid = 'entity_field_definitions:' . $entity_type . ':' . $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id; if ($cache = $this->cache->get($cid)) { $this->entityFieldInfo[$entity_type] = $cache->data; } diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index 899ae9f..aa5ba42 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -114,7 +114,7 @@ public function getType() { */ protected function init() { // We unset all defined properties, so magic getters apply. - unset($this->langcode); + unset($this->id); } /** @@ -367,7 +367,7 @@ public function onChange($property_name) { public function getTranslation($langcode, $strict = TRUE) { // If the default language is Language::LANGCODE_NOT_SPECIFIED, the entity is not // translatable, so we use Language::LANGCODE_DEFAULT. - if ($langcode == Language::LANGCODE_DEFAULT || in_array($this->language()->langcode, array(Language::LANGCODE_NOT_SPECIFIED, $langcode))) { + if ($langcode == Language::LANGCODE_DEFAULT || in_array($this->language()->id, array(Language::LANGCODE_NOT_SPECIFIED, $langcode))) { // No translation needed, return the entity. return $this; } @@ -431,7 +431,7 @@ public function getTranslationLanguages($include_default = TRUE) { unset($translations[Language::LANGCODE_DEFAULT]); if ($include_default) { - $translations[$this->language()->langcode] = TRUE; + $translations[$this->language()->id] = TRUE; } // Now load language objects based upon translation langcodes. return array_intersect_key(language_list(Language::STATE_ALL), $translations); diff --git a/core/lib/Drupal/Core/Entity/EntityRenderController.php b/core/lib/Drupal/Core/Entity/EntityRenderController.php index d202636..cd92f52 100644 --- a/core/lib/Drupal/Core/Entity/EntityRenderController.php +++ b/core/lib/Drupal/Core/Entity/EntityRenderController.php @@ -96,7 +96,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N */ public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) { if (!isset($langcode)) { - $langcode = language(Language::TYPE_CONTENT)->langcode; + $langcode = language(Language::TYPE_CONTENT)->id; } // Build the view modes and display objects. diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 0b9bbad..8b385ca 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -55,7 +55,7 @@ public function onRespond(FilterResponseEvent $event) { $response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', FALSE); // Set the Content-language header. - $response->headers->set('Content-language', $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->langcode); + $response->headers->set('Content-language', $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id); // Because pages are highly dynamic, set the last-modified time to now // since the page is in fact being regenerated right now. diff --git a/core/lib/Drupal/Core/EventSubscriber/LanguageRequestSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/LanguageRequestSubscriber.php index 518e66d..d50022d 100644 --- a/core/lib/Drupal/Core/EventSubscriber/LanguageRequestSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/LanguageRequestSubscriber.php @@ -59,7 +59,7 @@ public function onKernelRequestLanguage(GetResponseEvent $event) { $this->languageManager->setRequest($event->getRequest()); // After the language manager has initialized, set the default langcode // for the string translations. - $langcode = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->langcode; + $langcode = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id; $this->translation->setDefaultLangcode($langcode); } } diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php index 6e54b2d..da2f47b 100644 --- a/core/lib/Drupal/Core/Language/Language.php +++ b/core/lib/Drupal/Core/Language/Language.php @@ -19,6 +19,7 @@ class Language { // Properties within the Language are set up as the default language. public $name = ''; + public $id = ''; public $langcode = ''; public $direction = Language::DIRECTION_LTR; public $weight = 0; @@ -119,17 +120,17 @@ class Language { public function __construct(array $options = array()) { // Set all the provided properties for the language. foreach ($options as $name => $value) { - $this->$name = $value; + $this->{$name} = $value; } // If some options were not set, set sane defaults of a predefined language. if (!isset($options['name']) || !isset($options['direction'])) { $predefined = LanguageManager::getStandardLanguageList(); - if (isset($predefined[$this->langcode])) { + if (isset($predefined[$this->id])) { if (!isset($options['name'])) { - $this->name = $predefined[$this->langcode][0]; + $this->name = $predefined[$this->id][0]; } - if (!isset($options['direction']) && isset($predefined[$this->langcode][2])) { - $this->direction = $predefined[$this->langcode][2]; + if (!isset($options['direction']) && isset($predefined[$this->id][2])) { + $this->direction = $predefined[$this->id][2]; } } } diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php index 01f1d50..9ff0848 100644 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -157,6 +157,7 @@ protected function getLanguageTypes() { */ protected function getLanguageDefault() { $default_info = variable_get('language_default', array( + 'id' => 'en', 'langcode' => 'en', 'name' => 'English', 'direction' => 0, diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php index 17657e0..91805cb 100644 --- a/core/lib/Drupal/Core/Path/AliasManager.php +++ b/core/lib/Drupal/Core/Path/AliasManager.php @@ -103,7 +103,7 @@ public function getSystemPath($path, $path_language = NULL) { // language. If we used a language different from the one conveyed by the // requested URL, we might end up being unable to check if there is a path // alias matching the URL path. - $path_language = $path_language ?: $this->languageManager->getLanguage(Language::TYPE_URL)->langcode; + $path_language = $path_language ?: $this->languageManager->getLanguage(Language::TYPE_URL)->id; $original_path = $path; // Lookup the path alias first. if (!empty($path) && $source = $this->lookupPathSource($path, $path_language)) { @@ -121,7 +121,7 @@ public function getPathAlias($path, $path_language = NULL) { // language. If we used a language different from the one conveyed by the // requested URL, we might end up being unable to check if there is a path // alias matching the URL path. - $path_language = $path_language ?: $this->languageManager->getLanguage(Language::TYPE_URL)->langcode; + $path_language = $path_language ?: $this->languageManager->getLanguage(Language::TYPE_URL)->id; $result = $path; if (!empty($path) && $alias = $this->lookupPathAlias($path, $path_language)) { $result = $alias; diff --git a/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php index c663cf1..cfcf32e 100644 --- a/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php +++ b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php @@ -44,7 +44,7 @@ public function processInbound($path, Request $request) { * Implements Drupal\Core\PathProcessor\OutboundPathProcessorInterface::processOutbound(). */ public function processOutbound($path, &$options = array(), Request $request = NULL) { - $langcode = isset($options['language']) ? $options['language']->langcode : NULL; + $langcode = isset($options['language']) ? $options['language']->id : NULL; $path = $this->aliasManager->getPathAlias($path, $langcode); return $path; } diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index 6377ee6..7a1cdac 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -120,7 +120,7 @@ public function setCacheBackend(CacheBackendInterface $cache_backend, LanguageMa $this->languageManager = $language_manager; $this->cacheBackend = $cache_backend; $this->cacheKeyPrefix = $cache_key_prefix; - $this->cacheKey = $cache_key_prefix . ':' . $language_manager->getLanguage(Language::TYPE_INTERFACE)->langcode; + $this->cacheKey = $cache_key_prefix . ':' . $language_manager->getLanguage(Language::TYPE_INTERFACE)->id; } /** diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php index 63e543e..130ee9d 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php @@ -50,7 +50,7 @@ class TranslationManager implements TranslatorInterface { public function __construct() { // @todo Inject language_manager or config system after language_default // variable is converted to CMI. - $this->defaultLangcode = language_default()->langcode; + $this->defaultLangcode = language_default()->id; } /** diff --git a/core/lib/Drupal/Core/TypedData/Type/Language.php b/core/lib/Drupal/Core/TypedData/Type/Language.php index b910216..9db392c 100644 --- a/core/lib/Drupal/Core/TypedData/Type/Language.php +++ b/core/lib/Drupal/Core/TypedData/Type/Language.php @@ -39,11 +39,11 @@ class Language extends TypedData { */ public function getValue() { if (!empty($this->definition['settings']['langcode source'])) { - $this->langcode = $this->parent->__get($this->definition['settings']['langcode source']); + $this->id = $this->parent->__get($this->definition['settings']['langcode source']); } - if ($this->langcode) { - $language = language_load($this->langcode); - return $language ?: new LanguageObject(array('langcode' => $this->langcode)); + if ($this->id) { + $language = language_load($this->id); + return $language ?: new LanguageObject(array('langcode' => $this->id)); } } @@ -55,7 +55,7 @@ public function getValue() { public function setValue($value, $notify = TRUE) { // Support passing language objects. if (is_object($value)) { - $value = $value->langcode; + $value = $value->id; } elseif (isset($value) && !is_scalar($value)) { throw new InvalidArgumentException('Value is no valid langcode or language object.'); @@ -69,7 +69,7 @@ public function setValue($value, $notify = TRUE) { if ($notify && isset($this->parent)) { $this->parent->onChange($this->name); } - $this->langcode = $value; + $this->id = $value; } } diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php index ecc6781..df14d94 100644 --- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -56,7 +56,7 @@ public function setLocale($locale) { * Implements \Symfony\Component\Translation\TranslatorInterface::getLocale(). */ public function getLocale() { - return $this->locale ? $this->locale : language(Language::TYPE_INTERFACE)->langcode; + return $this->locale ? $this->locale : language(Language::TYPE_INTERFACE)->id; } /** diff --git a/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php b/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php index 91432ab..921b91a 100644 --- a/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php +++ b/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php @@ -89,7 +89,7 @@ public function execute($entity = NULL) { $langcode = user_preferred_langcode($recipient_account); } else { - $langcode = language_default()->langcode; + $langcode = language_default()->id; } $params = array('context' => $this->configuration); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php index 1e77d7c..ef25376 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php @@ -35,7 +35,7 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $feed->language()->langcode, + '#default_value' => $feed->language()->id, '#languages' => Language::STATE_ALL, ); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php index 12e41cd..2aa6731 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php @@ -39,7 +39,7 @@ public function __construct($type, \Traversable $namespaces) { ); $this->discovery = new AnnotatedClassDiscovery("aggregator/$type", $namespaces, $annotation_namespaces, $type_annotations[$type]); - $this->discovery = new CacheDecorator($this->discovery, "aggregator_$type:" . language(Language::TYPE_INTERFACE)->langcode); + $this->discovery = new CacheDecorator($this->discovery, "aggregator_$type:" . language(Language::TYPE_INTERFACE)->id); $this->factory = new DefaultFactory($this->discovery); } } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php index 79d9d07..8373fa9 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php @@ -128,7 +128,7 @@ public function process(Feed $feed) { $entry = reset($entry); } else { - $entry = entity_create('aggregator_item', array('langcode' => $feed->language()->langcode)); + $entry = entity_create('aggregator_item', array('langcode' => $feed->language()->id)); } if ($item['timestamp']) { $entry->timestamp->value = $item['timestamp']; diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/FeedLanguageTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/FeedLanguageTest.php index 611638a..ea841d5 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/FeedLanguageTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/FeedLanguageTest.php @@ -40,14 +40,14 @@ public function setUp() { parent::setUp(); // Create test languages. - $this->langcodes = array(language_load('en')); + $this->ids = array(language_load('en')); for ($i = 1; $i < 3; ++$i) { $language = new Language(array( - 'langcode' => 'l' . $i, + 'id' => 'l' . $i, 'name' => $this->randomString(), )); language_save($language); - $this->langcodes[$i] = $language; + $this->ids[$i] = $language; } } @@ -57,12 +57,12 @@ public function setUp() { public function testFeedLanguage() { $feeds = array(); // Create feeds. - $feeds[1] = $this->createFeed(NULL, array('langcode' => $this->langcodes[1]->langcode)); - $feeds[2] = $this->createFeed(NULL, array('langcode' => $this->langcodes[2]->langcode)); + $feeds[1] = $this->createFeed(NULL, array('langcode' => $this->ids[1]->id)); + $feeds[2] = $this->createFeed(NULL, array('langcode' => $this->ids[2]->id)); // Make sure that the language has been assigned. - $this->assertEqual($feeds[1]->language()->langcode, $this->langcodes[1]->langcode); - $this->assertEqual($feeds[2]->language()->langcode, $this->langcodes[2]->langcode); + $this->assertEqual($feeds[1]->language()->id, $this->ids[1]->id); + $this->assertEqual($feeds[2]->language()->id, $this->ids[2]->id); // Create example nodes to create feed items from and then update the feeds. $this->createSampleNodes(); @@ -74,7 +74,7 @@ public function testFeedLanguage() { $items = entity_load_multiple_by_properties('aggregator_item', array('fid' => $feed->id())); $this->assertTrue(count($items) > 0, 'Feed items were created.'); foreach ($items as $item) { - $this->assertEqual($item->language()->langcode, $feed->language()->langcode); + $this->assertEqual($item->language()->id, $feed->language()->id); } } } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index ca13d32..c7b4331 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -621,8 +621,8 @@ function block_language_delete($language) { // Remove the block visibility settings for the deleted language. foreach (entity_load_multiple('block') as $block_id => $block) { $visibility = $block->get('visibility'); - if (isset($visibility['language']['langcodes'][$language->langcode])) { - unset($visibility['language']['langcodes'][$language->langcode]); + if (isset($visibility['language']['langcodes'][$language->id])) { + unset($visibility['language']['langcodes'][$language->id]); $block->set('visibility', $visibility); $block->save(); } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php index 2457d97..27c1bd3 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php @@ -71,13 +71,13 @@ public function form(array $form, array &$form_state) { // Set the correct default language. if ($block->isNew() && !empty($language_configuration['langcode'])) { $language_default = language($language_configuration['langcode']); - $block->langcode->value = $language_default->langcode; + $block->id->value = $language_default->id; } $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $block->langcode->value, + '#default_value' => $block->id->value, '#languages' => Language::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php index 35f4b98..f2daf96 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php @@ -66,8 +66,8 @@ public function testCustomBlockTypeCreation() { $this->assertTrue($block_type, 'The new block type has been created.'); // Check that the block type was created in site default language. - $default_langcode = language_default()->langcode; - $this->assertEqual($block_type->langcode, $default_langcode); + $default_langcode = language_default()->id; + $this->assertEqual($block_type->id, $default_langcode); } /** diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php index 6df97d7..1584ae3 100644 --- a/core/modules/block/lib/Drupal/block/BlockAccessController.php +++ b/core/modules/block/lib/Drupal/block/BlockAccessController.php @@ -87,7 +87,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A // Language visibility settings. if (!empty($visibility['language']['langcodes']) && array_filter($visibility['language']['langcodes'])) { - if (empty($visibility['language']['langcodes'][language($visibility['language']['language_type'])->langcode])) { + if (empty($visibility['language']['langcodes'][language($visibility['language']['language_type'])->id])) { return FALSE; } } diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 828c5d4..f562a68 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -116,7 +116,7 @@ public function form(array $form, array &$form_state) { foreach ($languages as $language) { // @todo $language->name is not wrapped with t(), it should be replaced // by CMI translation implementation. - $langcodes_options[$language->langcode] = $language->name; + $langcodes_options[$language->id] = $language->name; } $form['visibility']['language'] = array( '#type' => 'details', diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php index 1dea798..631ee5e 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php @@ -41,14 +41,14 @@ public function setUp() { parent::setUp(); // Create test languages. - $this->langcodes = array(language_load('en')); + $this->ids = array(language_load('en')); for ($i = 1; $i < 3; ++$i) { $language = new Language(array( - 'langcode' => 'l' . $i, + 'id' => 'l' . $i, 'name' => $this->randomString(), )); language_save($language); - $this->langcodes[$i] = $language; + $this->ids[$i] = $language; } } @@ -68,7 +68,7 @@ public function testBlockLinks() { $this->drupalLogin($admin_user); // Create the block cache for all languages. - foreach ($this->langcodes as $langcode) { + foreach ($this->ids as $langcode) { $this->drupalGet('admin/structure/block', array('language' => $langcode)); $this->clickLink(t('Place blocks')); } @@ -78,7 +78,7 @@ public function testBlockLinks() { $feed = $this->createFeed(); // Check that the block is listed for all languages. - foreach ($this->langcodes as $langcode) { + foreach ($this->ids as $langcode) { $this->drupalGet('admin/structure/block', array('language' => $langcode)); $this->clickLink(t('Place blocks')); $this->assertText($feed->label()); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index 5990b2f..93b00f5 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -96,7 +96,7 @@ protected function createTests() { 'id' => 'stark.test_block', 'weight' => '', 'status' => '1', - 'langcode' => language_default()->langcode, + 'langcode' => language_default()->id, 'region' => '-1', 'plugin' => 'test_html_id', 'settings' => array( diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 1fe04c8..d3ea3ae 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -1127,7 +1127,7 @@ function template_preprocess_book_export_html(&$variables) { // HTML element attributes. $attributes = array(); - $attributes['lang'] = $language_interface->langcode; + $attributes['lang'] = $language_interface->id; $attributes['dir'] = $language_interface->direction ? 'rtl' : 'ltr'; $variables['html_attributes'] = new Attribute($attributes); } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php index 5ab4961..d24770e 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php @@ -172,7 +172,7 @@ public function getJSSettings(EditorEntity $editor) { 'toolbar' => $this->buildToolbarJSSetting($editor), 'contentsCss' => $this->buildContentsCssJSSetting($editor), 'extraPlugins' => implode(',', array_keys($external_plugins)), - 'language' => $language_interface->langcode, + 'language' => $language_interface->id, // Configure CKEditor to not load styles.js. The StylesCombo plugin will // set stylesSet according to the user's settings, if the "Styles" button // is enabled. We cannot get rid of this until CKEditor will stop loading diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index e2040d5..3341e5b 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -154,7 +154,7 @@ public function form(array $form, array &$form_state) { // set. if ($comment->isNew()) { $language_content = language(Language::TYPE_CONTENT); - $comment->langcode->value = $language_content->langcode; + $comment->id->value = $language_content->id; } // Add internal comment properties. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php index 47efe82..02f4587 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php @@ -123,8 +123,8 @@ function testCommentLanguage() { ->execute() ->fetchField(); $comment = comment_load($cid); - $args = array('%node_language' => $node_langcode, '%comment_language' => $comment->langcode->value, '%langcode' => $langcode); - $this->assertEqual($comment->langcode->value, $langcode, format_string('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args)); + $args = array('%node_language' => $node_langcode, '%comment_language' => $comment->id->value, '%langcode' => $langcode); + $this->assertEqual($comment->id->value, $langcode, format_string('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args)); $this->assertEqual($comment->comment_body->value, $comment_values[$node_langcode][$langcode], 'Comment body correctly stored.'); } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php index 608a8a4..0880901 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php @@ -62,8 +62,8 @@ function testCommentTokenReplacement() { $tests['[comment:body]'] = $comment->comment_body->processed; $tests['[comment:url]'] = url('comment/' . $comment->id(), $url_options + array('fragment' => 'comment-' . $comment->id())); $tests['[comment:edit-url]'] = url('comment/' . $comment->id() . '/edit', $url_options); - $tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->created->value, 2, $language_interface->langcode); - $tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->changed->value, 2, $language_interface->langcode); + $tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->created->value, 2, $language_interface->id); + $tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->changed->value, 2, $language_interface->id); $tests['[comment:parent:cid]'] = $comment->pid->target_id; $tests['[comment:parent:title]'] = check_plain($parent_comment->subject->value); $tests['[comment:node:nid]'] = $comment->nid->target_id; @@ -75,7 +75,7 @@ function testCommentTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized comment token %token replaced.', array('%token' => $input))); } @@ -91,7 +91,7 @@ function testCommentTokenReplacement() { $tests['[comment:author:name]'] = $this->admin_user->name; foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized comment token %token replaced.', array('%token' => $input))); } @@ -104,7 +104,7 @@ function testCommentTokenReplacement() { $tests['[node:comment-count-new]'] = 2; foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('node' => $node), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array('node' => $node), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Node comment token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php index 49d6814..97f0a60 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php @@ -104,7 +104,7 @@ protected function assertPublishedStatus() { // Check that simple users cannot see unpublished field translations. $path = $this->controller->getViewPath($entity); - foreach ($this->langcodes as $index => $langcode) { + foreach ($this->ids as $index => $langcode) { $translation = $this->getTranslation($entity, $langcode); $value = $this->getValue($translation, 'comment_body', $langcode); $this->drupalGet($path, array('language' => $languages[$langcode])); @@ -128,8 +128,8 @@ function testTranslateLinkCommentAdminPage() { $this->admin_user = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), array('access administration pages', 'administer comments'))); $this->drupalLogin($this->admin_user); - $cid_translatable = $this->createEntity(array(), $this->langcodes[0], $this->nodeBundle); - $cid_untranslatable = $this->createEntity(array(), $this->langcodes[0], 'page'); + $cid_translatable = $this->createEntity(array(), $this->ids[0], $this->nodeBundle); + $cid_untranslatable = $this->createEntity(array(), $this->ids[0], 'page'); // Verify translation links. $this->drupalGet('admin/content/comment'); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php index dfdd73c..8fc6583 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php @@ -35,14 +35,14 @@ public static function getInfo() { * Tests CRUD operations. */ function testCRUD() { - $default_langcode = language_default()->langcode; + $default_langcode = language_default()->id; // Verify default properties on a newly created empty entity. $empty = entity_create('config_test', array()); $this->assertIdentical($empty->id, NULL); $this->assertTrue($empty->uuid); $this->assertIdentical($empty->label, NULL); $this->assertIdentical($empty->style, NULL); - $this->assertIdentical($empty->langcode, $default_langcode); + $this->assertIdentical($empty->id, $default_langcode); // Verify ConfigEntity properties/methods on the newly created empty entity. $this->assertIdentical($empty->isNew(), TRUE); @@ -98,7 +98,7 @@ function testCRUD() { $this->assertNotEqual($config_test->uuid, $empty->uuid); $this->assertIdentical($config_test->label, $expected['label']); $this->assertIdentical($config_test->style, $expected['style']); - $this->assertIdentical($config_test->langcode, $default_langcode); + $this->assertIdentical($config_test->id, $default_langcode); // Verify methods on the newly created entity. $this->assertIdentical($config_test->isNew(), TRUE); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php index 6296ed5..9184bfb 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php @@ -58,7 +58,7 @@ function testImport() { 'weight' => '0', 'style' => '', 'status' => '1', - 'langcode' => language_default()->langcode, + 'langcode' => language_default()->id, 'protected_property' => '', ); $staging->write($dynamic_name, $original_dynamic_data); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php index aa133d5..05d8919 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php @@ -149,7 +149,7 @@ function testNew() { 'weight' => '0', 'style' => '', 'status' => '1', - 'langcode' => language_default()->langcode, + 'langcode' => language_default()->id, 'protected_property' => '', ); $staging->write($dynamic_name, $original_dynamic_data); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php index 4328892..79f22a9 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php @@ -67,15 +67,15 @@ function testConfigLocaleUserOverride() { $this->installConfig(array('language')); language_save(new Language(array( 'name' => 'French', - 'langcode' => 'fr', + 'id' => 'fr', ))); language_save(new Language(array( 'name' => 'English', - 'langcode' => 'en', + 'id' => 'en', ))); language_save(new Language(array( 'name' => 'German', - 'langcode' => 'de', + 'id' => 'de', ))); $this->installSchema('user', 'users'); @@ -157,15 +157,15 @@ function testConfigLocaleLanguageOverride() { $this->installConfig(array('language')); language_save(new Language(array( 'name' => 'French', - 'langcode' => 'fr', + 'id' => 'fr', ))); language_save(new Language(array( 'name' => 'English', - 'langcode' => 'en', + 'id' => 'en', ))); language_save(new Language(array( 'name' => 'German', - 'langcode' => 'de', + 'id' => 'de', ))); $language = language_load('fr'); @@ -234,7 +234,7 @@ function testConfigLocaleUserAndGlobalOverride() { $this->installConfig(array('language')); language_save(new Language(array( 'name' => 'French', - 'langcode' => 'fr', + 'id' => 'fr', ))); $this->installSchema('user', 'users'); diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 64d97b2..972aae3 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -277,14 +277,14 @@ function contact_mail($key, &$message, $params) { $variables['!sender-url'] = $params['sender']->mail; } - $options = array('langcode' => $language->langcode); + $options = array('langcode' => $language->id); switch ($key) { case 'page_mail': case 'page_copy': $message['subject'] .= t('[!category] !subject', $variables, $options); $message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, $options); - $build = entity_view($contact_message, 'mail', $language->langcode); + $build = entity_view($contact_message, 'mail', $language->id); $message['body'][] = drupal_render($build); break; @@ -303,7 +303,7 @@ function contact_mail($key, &$message, $params) { $message['body'][] = t('Hello !recipient-name,', $variables, $options); $message['body'][] = t("!sender-name (!sender-url) has sent you a message via your contact form at !site-name.", $variables, $options); $message['body'][] = t("If you don't want to receive such e-mails, you can change your settings at !recipient-edit-url.", $variables, $options); - $build = entity_view($contact_message, 'mail', $language->langcode); + $build = entity_view($contact_message, 'mail', $language->id); $message['body'][] = drupal_render($build); break; } diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php index f64dbe0..bf807a6 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php @@ -159,7 +159,7 @@ public function save(array $form, array &$form_state) { $params['contact_category'] = $category; $to = implode(', ', $category->recipients); - $recipient_langcode = language_default()->langcode; + $recipient_langcode = language_default()->id; } elseif ($recipient = $message->getPersonalRecipient()) { // Send to the user in the user's preferred language. @@ -177,14 +177,14 @@ public function save(array $form, array &$form_state) { // If requested, send a copy to the user, using the current language. if ($message->copySender()) { - drupal_mail('contact', $key_prefix . '_copy', $sender->mail, $language_interface->langcode, $params, $sender->mail); + drupal_mail('contact', $key_prefix . '_copy', $sender->mail, $language_interface->id, $params, $sender->mail); } // If configured, send an auto-reply, using the current language. if (!$message->isPersonal() && $category->reply) { // User contact forms do not support an auto-reply message, so this // message always originates from the site. - drupal_mail('contact', 'page_autoreply', $sender->mail, $language_interface->langcode, $params); + drupal_mail('contact', 'page_autoreply', $sender->mail, $language_interface->id, $params); } \Drupal::service('flood')->register('contact', config('contact.settings')->get('flood.interval')); diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php index 24ba989..0556048 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php @@ -110,7 +110,7 @@ function testSiteWideContact() { // Check that the category was created in site default language. $langcode = config('contact.category.' . $id)->get('langcode'); - $default_langcode = language_default()->langcode; + $default_langcode = language_default()->id; $this->assertEqual($langcode, $default_langcode); // Make sure the newly created category is included in the list of categories. diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 9755c86..01c271f 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -535,7 +535,7 @@ function content_translation_translatable_batch($translatable, $field_name, &$co $context['sandbox']['max_entity_type'][$entity_type] -= count($result); $context['sandbox']['progress_entity_type'][$entity_type]++; $context['sandbox']['progress']++; - $langcode = $entity->language()->langcode; + $langcode = $entity->language()->id; // Skip process for language neutral entities. if ($langcode == Language::LANGCODE_NOT_SPECIFIED) { diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index c0c3535..8601355 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -316,7 +316,7 @@ function content_translation_add_access(EntityInterface $entity, Language $sourc $target = !empty($target) ? $target : language(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); - return $source->langcode != $target->langcode && isset($languages[$source->langcode]) && isset($languages[$target->langcode]) && !isset($translations[$target->langcode]) && content_translation_access($entity, 'create'); + return $source->id != $target->id && isset($languages[$source->id]) && isset($languages[$target->id]) && !isset($translations[$target->id]) && content_translation_access($entity, 'create'); } /** @@ -332,7 +332,7 @@ function content_translation_edit_access(EntityInterface $entity, Language $lang $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); - return isset($languages[$language->langcode]) && $language->langcode != $entity->language()->langcode && isset($translations[$language->langcode]) && content_translation_access($entity, 'update'); + return isset($languages[$language->id]) && $language->id != $entity->language()->id && isset($translations[$language->id]) && content_translation_access($entity, 'update'); } /** @@ -348,7 +348,7 @@ function content_translation_delete_access(EntityInterface $entity, Language $la $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); - return isset($languages[$language->langcode]) && $language->langcode != $entity->language()->langcode && isset($translations[$language->langcode]) && content_translation_access($entity, 'delete'); + return isset($languages[$language->id]) && $language->id != $entity->language()->id && isset($translations[$language->id]) && content_translation_access($entity, 'delete'); } /** @@ -645,7 +645,7 @@ function content_translation_field_language_alter(&$display_language, $context) $instances = field_info_instances($entity_type, $entity->bundle()); // Avoid altering the real entity. $entity = clone($entity); - $entity_langcode = $entity->language()->langcode; + $entity_langcode = $entity->language()->id; foreach ($entity->translation as $langcode => $translation) { if ($langcode == $context['langcode'] || !content_translation_view_access($entity, $langcode)) { @@ -705,7 +705,7 @@ function content_translation_load_translation_metadata(array $entities, $entity_ // @todo Declare these as entity (translation?) properties. foreach ($record as $field_name => $value) { if (!in_array($field_name, $exclude)) { - $entity->translation[$record->langcode][$field_name] = $value; + $entity->translation[$record->id][$field_name] = $value; } } } diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index 2940585..045ffdc 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -19,7 +19,7 @@ function content_translation_overview(EntityInterface $entity) { $controller = content_translation_controller($entity->entityType()); $entity_manager = Drupal::entityManager(); $languages = language_list(); - $original = $entity->language()->langcode; + $original = $entity->language()->id; $translations = $entity->getTranslationLanguages(); $field_ui = module_exists('field_ui') && user_access('administer ' . $entity->entityType() . ' fields'); @@ -50,7 +50,7 @@ function content_translation_overview(EntityInterface $entity) { foreach ($languages as $language) { $language_name = $language->name; - $langcode = $language->langcode; + $langcode = $language->id; $add_path = $base_path . '/translations/add/' . $original . '/' . $langcode; $translate_path = $base_path . '/translations/edit/' . $langcode; $delete_path = $base_path . '/translations/delete/' . $langcode; @@ -117,7 +117,7 @@ function content_translation_overview(EntityInterface $entity) { else { // No such translation in the set yet: help user to create it. $row_title = $source_name = t('n/a'); - $source = $entity->language()->langcode; + $source = $entity->language()->id; if ($source != $langcode && $controller->getTranslationAccess($entity, 'create')) { if ($translatable) { @@ -197,7 +197,7 @@ function content_translation_add_page(EntityInterface $entity, Language $source content_translation_prepare_translation($entity, $source, $target); $info = $entity->entityInfo(); $operation = isset($info['default_operation']) ? $info['default_operation'] : 'default'; - $form_state['langcode'] = $target->langcode; + $form_state['langcode'] = $target->id; $form_state['content_translation']['source'] = $source; $form_state['content_translation']['target'] = $target; $controller = content_translation_controller($entity->entityType()); @@ -221,7 +221,7 @@ function content_translation_edit_page(EntityInterface $entity, Language $langua $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); $info = $entity->entityInfo(); $operation = isset($info['default_operation']) ? $info['default_operation'] : 'default'; - $form_state['langcode'] = $language->langcode; + $form_state['langcode'] = $language->id; $form_state['content_translation']['translation_form'] = TRUE; return Drupal::entityManager()->getForm($entity, $operation, $form_state); } @@ -241,8 +241,8 @@ function content_translation_prepare_translation(EntityInterface $entity, Langua $instances = field_info_instances($entity->entityType(), $entity->bundle()); $entity = $entity->getNGEntity(); if ($entity instanceof EntityNG) { - $source_translation = $entity->getTranslation($source->langcode); - $target_translation = $entity->getTranslation($target->langcode); + $source_translation = $entity->getTranslation($source->id); + $target_translation = $entity->getTranslation($target->id); foreach ($target_translation->getPropertyDefinitions() as $property_name => $definition) { // @todo The "key" part should not be needed. Remove it as soon as things // do not break. @@ -255,7 +255,7 @@ function content_translation_prepare_translation(EntityInterface $entity, Langua $field = field_info_field($field_name); if (!empty($field['translatable'])) { $value = $entity->get($field_name); - $value[$target->langcode] = isset($value[$source->langcode]) ? $value[$source->langcode] : array(); + $value[$target->id] = isset($value[$source->id]) ? $value[$source->id] : array(); $entity->set($field_name, $value); } } @@ -266,7 +266,7 @@ function content_translation_prepare_translation(EntityInterface $entity, Langua * Form constructor for the translation deletion confirmation. */ function content_translation_delete_confirm(array $form, array $form_state, EntityInterface $entity, Language $language) { - $langcode = $language->langcode; + $langcode = $language->id; $controller = content_translation_controller($entity->entityType()); return confirm_form( @@ -287,13 +287,13 @@ function content_translation_delete_confirm_submit(array $form, array &$form_sta $controller = content_translation_controller($entity->entityType()); // Remove the translated values. - $controller->removeTranslation($entity, $language->langcode); + $controller->removeTranslation($entity, $language->id); $entity->save(); // Remove any existing path alias for the removed translation. // @todo This should be taken care of by the Path module. if (module_exists('path')) { - $conditions = array('source' => $controller->getViewPath($entity), 'langcode' => $language->langcode); + $conditions = array('source' => $controller->getViewPath($entity), 'langcode' => $language->id); drupal_container()->get('path.crud')->delete($conditions); } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php index 944ec69..a9e4a56 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php @@ -62,7 +62,7 @@ public function removeTranslation(EntityInterface $entity, $langcode) { * Implements ContentTranslationControllerInterface::retranslate(). */ public function retranslate(EntityInterface $entity, $langcode = NULL) { - $updated_langcode = !empty($langcode) ? $langcode : $entity->language()->langcode; + $updated_langcode = !empty($langcode) ? $langcode : $entity->language()->id; $translations = $entity->getTranslationLanguages(); foreach ($translations as $langcode => $language) { $entity->translation[$langcode]['outdated'] = $langcode != $updated_langcode; @@ -117,7 +117,7 @@ public function getTranslationAccess(EntityInterface $entity, $op) { * Implements ContentTranslationControllerInterface::getSourceLanguage(). */ public function getSourceLangcode(array $form_state) { - return isset($form_state['content_translation']['source']) ? $form_state['content_translation']['source']->langcode : FALSE; + return isset($form_state['content_translation']['source']) ? $form_state['content_translation']['source']->id : FALSE; } /** @@ -126,7 +126,7 @@ public function getSourceLangcode(array $form_state) { public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { $form_controller = content_translation_form_controller($form_state); $form_langcode = $form_controller->getFormLangcode($form_state); - $entity_langcode = $entity->language()->langcode; + $entity_langcode = $entity->language()->id; $source_langcode = $this->getSourceLangcode($form_state); $new_translation = !empty($source_langcode); @@ -144,7 +144,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac if (isset($languages[$form_langcode]) && ($has_translations || $new_translation)) { $title = $this->entityFormTitle($entity); // When editing the original values display just the entity label. - if ($form_langcode != $entity->language()->langcode) { + if ($form_langcode != $entity->language()->id) { $t_args = array('%language' => $languages[$form_langcode]->name, '%title' => $entity->label()); $title = empty($source_langcode) ? $title . ' [' . t('%language translation', $t_args) . ']' : t('Create %language translation of %title', $t_args); } @@ -173,8 +173,8 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac ), ); foreach (language_list(Language::STATE_CONFIGURABLE) as $language) { - if (isset($translations[$language->langcode])) { - $form['source_langcode']['source']['#options'][$language->langcode] = $language->name; + if (isset($translations[$language->id])) { + $form['source_langcode']['source']['#options'][$language->id] = $language->name; } } } @@ -186,8 +186,8 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac if ($language_widget && $has_translations) { $form['langcode']['#options'] = array(); foreach (language_list(Language::STATE_CONFIGURABLE) as $language) { - if (empty($translations[$language->langcode]) || $language->langcode == $entity_langcode) { - $form['langcode']['#options'][$language->langcode] = $language->name; + if (empty($translations[$language->id]) || $language->id == $entity_langcode) { + $form['langcode']['#options'][$language->id] = $language->name; } } } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php index 45a6c91..b1902f8 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php @@ -55,7 +55,7 @@ public function synchronizeFields(EntityInterface $entity, $sync_langcode, $orig // If the entity language is being changed there is nothing to synchronize. $entity_type = $entity->entityType(); $entity_unchanged = isset($entity->original) ? $entity->original : $this->entityManager->getStorageController($entity_type)->loadUnchanged($entity->id()); - if ($entity->language()->langcode != $entity_unchanged->language()->langcode) { + if ($entity->language()->id != $entity_unchanged->language()->id) { return; } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ConfigTestTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ConfigTestTranslationUITest.php index 5765cd4..5ae32d6 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ConfigTestTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ConfigTestTranslationUITest.php @@ -61,7 +61,7 @@ protected function getNewEntityValues($langcode) { */ function testTranslationUI() { // Create a new test entity with original values in the default language. - $default_langcode = $this->langcodes[0]; + $default_langcode = $this->ids[0]; $values[$default_langcode] = $this->getNewEntityValues($default_langcode); $id = $this->createEntity($values[$default_langcode], $default_langcode); $entity = entity_load($this->entityType, $id, TRUE); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php index 7bfa73f..7a2f824 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php @@ -82,8 +82,8 @@ protected function setupTestFields() { * Tests image field field synchronization. */ function testImageFieldSync() { - $default_langcode = $this->langcodes[0]; - $langcode = $this->langcodes[1]; + $default_langcode = $this->ids[0]; + $langcode = $this->ids[1]; // Populate the required contextual values. $attributes = $this->container->get('request')->attributes; diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php index ab59812..5a060e0 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php @@ -74,17 +74,17 @@ protected function setUp() { $this->synchronizer = new FieldTranslationSynchronizer($this->container->get('plugin.manager.entity')); $this->synchronized = array('sync1', 'sync2'); $this->columns = array_merge($this->synchronized, array('var1', 'var2')); - $this->langcodes = array('en', 'it', 'fr', 'de', 'es'); + $this->ids = array('en', 'it', 'fr', 'de', 'es'); $this->cardinality = 4; $this->unchangedFieldValues = array(); // Set up an initial set of values in the correct state, that is with // "synchronized" values being equal. - foreach ($this->langcodes as $langcode) { + foreach ($this->ids as $langcode) { for ($delta = 0; $delta < $this->cardinality; $delta++) { foreach ($this->columns as $column) { - $sync = in_array($column, $this->synchronized) && $langcode != $this->langcodes[0]; - $value = $sync ? $this->unchangedFieldValues[$this->langcodes[0]][$delta][$column] : $langcode . '-' . $delta . '-' . $column; + $sync = in_array($column, $this->synchronized) && $langcode != $this->ids[0]; + $value = $sync ? $this->unchangedFieldValues[$this->ids[0]][$delta][$column] : $langcode . '-' . $delta . '-' . $column; $this->unchangedFieldValues[$langcode][$delta][$column] = $value; } } @@ -97,7 +97,7 @@ protected function setUp() { public function testFieldSync() { // Add a new item to the source items and check that its added to all the // translations. - $sync_langcode = $this->langcodes[2]; + $sync_langcode = $this->ids[2]; $unchanged_items = $this->unchangedFieldValues[$sync_langcode]; $field_values = $this->unchangedFieldValues; $item = array(); @@ -105,7 +105,7 @@ public function testFieldSync() { $item[$column] = $this->randomName(); } $field_values[$sync_langcode][] = $item; - $this->synchronizer->synchronizeItems($field_values, $unchanged_items, $sync_langcode, $this->langcodes, $this->synchronized); + $this->synchronizer->synchronizeItems($field_values, $unchanged_items, $sync_langcode, $this->ids, $this->synchronized); $result = TRUE; foreach ($this->unchangedFieldValues as $langcode => $items) { // Check that the old values are still in place. @@ -123,14 +123,14 @@ public function testFieldSync() { // Remove an item from the source items and check that its removed from all // the translations. - $sync_langcode = $this->langcodes[1]; + $sync_langcode = $this->ids[1]; $unchanged_items = $this->unchangedFieldValues[$sync_langcode]; $field_values = $this->unchangedFieldValues; $sync_delta = mt_rand(0, count($field_values[$sync_langcode]) - 1); unset($field_values[$sync_langcode][$sync_delta]); // Renumber deltas to start from 0. $field_values[$sync_langcode] = array_values($field_values[$sync_langcode]); - $this->synchronizer->synchronizeItems($field_values, $unchanged_items, $sync_langcode, $this->langcodes, $this->synchronized); + $this->synchronizer->synchronizeItems($field_values, $unchanged_items, $sync_langcode, $this->ids, $this->synchronized); $result = TRUE; foreach ($this->unchangedFieldValues as $langcode => $items) { $new_delta = 0; @@ -149,7 +149,7 @@ public function testFieldSync() { // Move the items around in the source items and check that they are moved // in all the translations. - $sync_langcode = $this->langcodes[3]; + $sync_langcode = $this->ids[3]; $unchanged_items = $this->unchangedFieldValues[$sync_langcode]; $field_values = $this->unchangedFieldValues; $field_values[$sync_langcode] = array(); @@ -160,7 +160,7 @@ public function testFieldSync() { } // Renumber deltas to start from 0. ksort($field_values[$sync_langcode]); - $this->synchronizer->synchronizeItems($field_values, $unchanged_items, $sync_langcode, $this->langcodes, $this->synchronized); + $this->synchronizer->synchronizeItems($field_values, $unchanged_items, $sync_langcode, $this->ids, $this->synchronized); $result = TRUE; foreach ($field_values as $langcode => $items) { for ($delta = 0; $delta < $this->cardinality; $delta++) { @@ -186,7 +186,7 @@ public function testFieldSync() { * Tests that items holding the same values are correctly synchronized. */ public function testMultipleSyncedValues() { - $sync_langcode = $this->langcodes[1]; + $sync_langcode = $this->ids[1]; $unchanged_items = $this->unchangedFieldValues[$sync_langcode]; // Determine whether the unchanged values should be altered depending on @@ -214,7 +214,7 @@ function($delta) { return $delta === 0 || $delta === 3; }, } $changed_items = $field_values[$sync_langcode]; - $this->synchronizer->synchronizeItems($field_values, $unchanged_items, $sync_langcode, $this->langcodes, $this->synchronized); + $this->synchronizer->synchronizeItems($field_values, $unchanged_items, $sync_langcode, $this->ids, $this->synchronized); $result = TRUE; foreach ($this->unchangedFieldValues as $langcode => $unchanged_items) { @@ -236,7 +236,7 @@ function($delta) { return $delta === 0 || $delta === 3; }, * Tests that one change in a synchronized column triggers a change in all columns. */ public function testDifferingSyncedColumns() { - $sync_langcode = $this->langcodes[2]; + $sync_langcode = $this->ids[2]; $unchanged_items = $this->unchangedFieldValues[$sync_langcode]; $field_values = $this->unchangedFieldValues; @@ -246,7 +246,7 @@ public function testDifferingSyncedColumns() { } $changed_items = $field_values[$sync_langcode]; - $this->synchronizer->synchronizeItems($field_values, $unchanged_items, $sync_langcode, $this->langcodes, $this->synchronized); + $this->synchronizer->synchronizeItems($field_values, $unchanged_items, $sync_langcode, $this->ids, $this->synchronized); $result = TRUE; foreach ($this->unchangedFieldValues as $langcode => $unchanged_items) { diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php index a454b8a..2fda54b 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php @@ -92,11 +92,11 @@ function setUp() { * Enables additional languages. */ protected function setupLanguages() { - $this->langcodes = array('it', 'fr'); - foreach ($this->langcodes as $langcode) { - language_save(new Language(array('langcode' => $langcode))); + $this->ids = array('it', 'fr'); + foreach ($this->ids as $langcode) { + language_save(new Language(array('id' => $langcode))); } - array_unshift($this->langcodes, language_default()->langcode); + array_unshift($this->ids, language_default()->id); } /** diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php index 6ffad4f..73af0b0 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php @@ -47,7 +47,7 @@ function testTranslationUI() { */ protected function assertBasicTranslation() { // Create a new test entity with original values in the default language. - $default_langcode = $this->langcodes[0]; + $default_langcode = $this->ids[0]; $values[$default_langcode] = $this->getNewEntityValues($default_langcode); $this->entityId = $this->createEntity($values[$default_langcode], $default_langcode); $entity = entity_load($this->entityType, $this->entityId, TRUE); @@ -105,7 +105,7 @@ protected function assertBasicTranslation() { protected function assertOutdatedStatus() { $entity = entity_load($this->entityType, $this->entityId, TRUE); $langcode = 'fr'; - $default_langcode = $this->langcodes[0]; + $default_langcode = $this->ids[0]; // Mark translations as outdated. $edit = array('content_translation[retranslate]' => TRUE); @@ -113,7 +113,7 @@ protected function assertOutdatedStatus() { $entity = entity_load($this->entityType, $this->entityId, TRUE); // Check that every translation has the correct "outdated" status. - foreach ($this->langcodes as $enabled_langcode) { + foreach ($this->ids as $enabled_langcode) { $prefix = $enabled_langcode != $default_langcode ? $enabled_langcode . '/' : ''; $path = $prefix . $this->controller->getEditPath($entity); $this->drupalGet($path); @@ -140,7 +140,7 @@ protected function assertPublishedStatus() { $path = $this->controller->getEditPath($entity); // Unpublish translations. - foreach ($this->langcodes as $index => $langcode) { + foreach ($this->ids as $index => $langcode) { if ($index > 0) { $edit = array('content_translation[status]' => FALSE); $this->drupalPost($langcode . '/' . $path, $edit, $this->getFormSubmitAction($entity)); @@ -163,7 +163,7 @@ protected function assertAuthoringInfo() { $values = array(); // Post different authoring information for each translation. - foreach ($this->langcodes as $index => $langcode) { + foreach ($this->ids as $index => $langcode) { $user = $this->drupalCreateUser(); $values[$langcode] = array( 'uid' => $user->uid, @@ -178,7 +178,7 @@ protected function assertAuthoringInfo() { } $entity = entity_load($this->entityType, $this->entityId, TRUE); - foreach ($this->langcodes as $langcode) { + foreach ($this->ids as $langcode) { $this->assertEqual($entity->translation[$langcode]['uid'] == $values[$langcode]['uid'], 'Translation author correctly stored.'); $this->assertEqual($entity->translation[$langcode]['created'] == $values[$langcode]['created'], 'Translation date correctly stored.'); } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php index 4930283..efcc48d 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php @@ -53,7 +53,7 @@ protected function getEditorPermissions() { * Creates a test entity and translate it. */ protected function setupEntity() { - $default_langcode = $this->langcodes[0]; + $default_langcode = $this->ids[0]; // Create a test entity. $values = array( @@ -66,7 +66,7 @@ protected function setupEntity() { // Create a translation. $this->drupalLogin($this->translator); - $add_translation_path = $this->controller->getBasePath($this->entity) . "/translations/add/$default_langcode/{$this->langcodes[2]}"; + $add_translation_path = $this->controller->getBasePath($this->entity) . "/translations/add/$default_langcode/{$this->ids[2]}"; $this->drupalPost($add_translation_path, array(), t('Save')); $this->rebuildContainer(); } @@ -116,7 +116,7 @@ function testWorkflows() { * status as value. */ protected function assertWorkflows(UserInterface $user, $expected_status) { - $default_langcode = $this->langcodes[0]; + $default_langcode = $this->ids[0]; $languages = language_list(); $args = array('@user_label' => $user->name); $this->drupalLogin($user); @@ -128,7 +128,7 @@ protected function assertWorkflows(UserInterface $user, $expected_status) { $this->assertResponse($expected_status['edit'], format_string('The @user_label has the expected edit access.', $args)); // Check whether the user is allowed to access the translation overview. - $langcode = $this->langcodes[1]; + $langcode = $this->ids[1]; $translations_path = $this->controller->getBasePath($this->entity) . "/translations"; $options = array('language' => $languages[$langcode]); $this->drupalGet($translations_path, $options); @@ -151,7 +151,7 @@ protected function assertWorkflows(UserInterface $user, $expected_status) { $this->assertResponse($expected_status['add_translation'], format_string('The @user_label has the expected translation creation access.', $args)); // Check whether the user is allowed to edit a translation. - $langcode = $this->langcodes[2]; + $langcode = $this->ids[2]; $edit_translation_path = $translations_path . "/edit/$langcode"; $options = array('language' => $languages[$langcode]); if ($expected_status['edit_translation'] == 200) { diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 057027d..d46ff07 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -669,11 +669,11 @@ function hook_field_storage_load($entity_type, $entities, $age, $fields, $option $delta_count = array(); foreach ($results as $row) { - if (!isset($delta_count[$row->entity_id][$row->langcode])) { - $delta_count[$row->entity_id][$row->langcode] = 0; + if (!isset($delta_count[$row->entity_id][$row->id])) { + $delta_count[$row->entity_id][$row->id] = 0; } - if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $field['cardinality']) { + if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->id] < $field['cardinality']) { $item = array(); // For each column declared by the field, populate the item // from the prefixed database column. @@ -683,8 +683,8 @@ function hook_field_storage_load($entity_type, $entities, $age, $fields, $option } // Add the item to the field values for the entity. - $entities[$row->entity_id]->{$field_name}[$row->langcode][] = $item; - $delta_count[$row->entity_id][$row->langcode]++; + $entities[$row->entity_id]->{$field_name}[$row->id][] = $item; + $delta_count[$row->entity_id][$row->id]++; } } } diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index f9c585e..4b4d93f 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -782,7 +782,7 @@ function field_attach_form_validate(EntityInterface $entity, $form, &$form_state $has_violations = TRUE; // Place violations in $form_state. - $langcode = field_is_translatable($entity->entityType(), field_info_field($field_name)) ? $entity->language()->langcode : Language::LANGCODE_NOT_SPECIFIED; + $langcode = field_is_translatable($entity->entityType(), field_info_field($field_name)) ? $entity->language()->id : Language::LANGCODE_NOT_SPECIFIED; $field_state = field_form_get_state($form['#parents'], $field_name, $langcode, $form_state); $field_state['constraint_violations'] = $field_violations; field_form_set_state($form['#parents'], $field_name, $langcode, $form_state, $field_state); diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc index 667a71a..99119af 100644 --- a/core/modules/field/field.info.inc +++ b/core/modules/field/field.info.inc @@ -70,7 +70,7 @@ function _field_info_collate_types() { // The _info() hooks invoked below include translated strings, so each // language is cached separately. - $langcode = $language_interface->langcode; + $langcode = $language_interface->id; if (!isset($info)) { if ($cached = cache('field')->get("field_info_types:$langcode")) { diff --git a/core/modules/field/field.module b/core/modules/field/field.module index d73991c..3998dbc 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -255,7 +255,7 @@ function field_populate_default_values(EntityInterface $entity, $langcode = NULL $entity = $entity->getBCEntity(); $entity_type = $entity->entityType(); - $langcode = $langcode ?: $entity->language()->langcode; + $langcode = $langcode ?: $entity->language()->id; foreach (field_info_instances($entity_type, $entity->bundle()) as $field_name => $instance) { $field = field_info_field($field_name); $field_langcode = field_is_translatable($entity_type, $field) ? $langcode : Language::LANGCODE_NOT_SPECIFIED; diff --git a/core/modules/field/field.multilingual.inc b/core/modules/field/field.multilingual.inc index c04c218..ca33a31 100644 --- a/core/modules/field/field.multilingual.inc +++ b/core/modules/field/field.multilingual.inc @@ -220,7 +220,7 @@ function field_valid_language($langcode, $default = TRUE) { if (in_array($langcode, $languages)) { return $langcode; } - return $default ? language_default()->langcode : language(Language::TYPE_CONTENT)->langcode; + return $default ? language_default()->id : language(Language::TYPE_CONTENT)->id; } /** @@ -275,8 +275,8 @@ function field_language(EntityInterface $entity, $field_name = NULL, $langcode = // Language::LANGCODE_NOT_SPECIFIED. $display_langcode[$instance['field_name']] = Language::LANGCODE_NOT_SPECIFIED; foreach (language_list(Language::STATE_LOCKED) as $language_locked) { - if (isset($entity->{$instance['field_name']}[$language_locked->langcode])) { - $display_langcode[$instance['field_name']] = $language_locked->langcode; + if (isset($entity->{$instance['field_name']}[$language_locked->id])) { + $display_langcode[$instance['field_name']] = $language_locked->id; break; } } diff --git a/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigField.php b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigField.php index ca37842..bfbf092 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigField.php +++ b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigField.php @@ -40,7 +40,7 @@ public function validate() { $this->legacyCallback('validate', array(&$legacy_errors)); $entity = $this->getParent(); - $langcode = $entity->language()->langcode; + $langcode = $entity->language()->id; if (isset($legacy_errors[$this->getInstance()->getField()->id()][$langcode])) { foreach ($legacy_errors[$this->getInstance()->getField()->id()][$langcode] as $delta => $item_errors) { @@ -106,7 +106,7 @@ protected function legacyCallback($hook, $args = array()) { $callback = "{$module}_field_{$hook}"; if (function_exists($callback)) { $entity = $this->getParent(); - $langcode = $entity->language()->langcode; + $langcode = $entity->language()->id; // We need to remove the empty "prototype" item here. // @todo Revisit after http://drupal.org/node/1988492. diff --git a/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php index d965401..39066a5 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php +++ b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php @@ -86,7 +86,7 @@ public function instanceSettingsForm(array $form, array &$form_state) { public function prepareCache() { if ($callback = $this->getLegacyCallback('load')) { $entity = $this->getParent()->getParent(); - $langcode = $entity->language()->langcode; + $langcode = $entity->language()->id; $entity_id = $entity->id(); // hook_field_attach_load() receives items keyed by entity id, and alter @@ -130,7 +130,7 @@ public static function prepareView(array $entities_items) { // Determine the entity type, langcode and field. $entity_type = current($entities)->entityType(); - $langcode = current($entities)->language()->langcode; + $langcode = current($entities)->language()->id; $field = current($instances)->getField(); $args = array( diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php index 0ae63b7..3604142 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -226,9 +226,9 @@ public function query($use_groupby = FALSE) { $column = $this->tableAlias . '.langcode'; // By the same reason as field_language the field might be Language::LANGCODE_NOT_SPECIFIED in reality so allow it as well. // @see this::field_langcode() - $default_langcode = language_default()->langcode; + $default_langcode = language_default()->id; $langcode = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'), - array(drupal_container()->get(Language::TYPE_CONTENT)->langcode, $default_langcode), + array(drupal_container()->get(Language::TYPE_CONTENT)->id, $default_langcode), $this->view->display_handler->options['field_langcode']); $placeholder = $this->placeholder(); $langcode_fallback_candidates = array($langcode); @@ -831,9 +831,9 @@ protected function addSelfTokens(&$tokens, $item) { */ function field_langcode(EntityInterface $entity) { if (field_is_translatable($entity->entityType(), $this->field_info)) { - $default_langcode = language_default()->langcode; + $default_langcode = language_default()->id; $langcode = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'), - array(drupal_container()->get(Language::TYPE_CONTENT)->langcode, $default_langcode), + array(drupal_container()->get(Language::TYPE_CONTENT)->id, $default_langcode), $this->view->display_handler->options['field_language']); // Give the Field Language API a chance to fallback to a different language diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php index 29a4955..383b640 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php @@ -103,7 +103,7 @@ function setUp() { for ($i = 0; $i < 3; ++$i) { $language = new Language(array( - 'langcode' => 'l' . $i, + 'id' => 'l' . $i, 'name' => $this->randomString(), )); language_save($language); diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php index 7001ad0..b7ac855 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php @@ -85,7 +85,7 @@ function setUp() { for ($i = 0; $i < 3; ++$i) { $language = new Language(array( - 'langcode' => 'l' . $i, + 'id' => 'l' . $i, 'name' => $this->randomString(), )); language_save($language); diff --git a/core/modules/field/tests/modules/field_test/field_test.storage.inc b/core/modules/field/tests/modules/field_test/field_test.storage.inc index d3a7f82..baeaf48 100644 --- a/core/modules/field/tests/modules/field_test/field_test.storage.inc +++ b/core/modules/field/tests/modules/field_test/field_test.storage.inc @@ -95,17 +95,17 @@ function field_test_field_storage_load($entity_type, $entities, $age, $fields, $ foreach ($field_data[$sub_table] as $row) { if ($row->type == $entity_type && (!$row->deleted || $options['deleted'])) { if (($load_current && in_array($row->entity_id, $ids)) || (!$load_current && in_array($row->revision_id, $ids))) { - if (in_array($row->langcode, field_available_languages($entity_type, $field))) { - if (!isset($delta_count[$row->entity_id][$row->langcode])) { - $delta_count[$row->entity_id][$row->langcode] = 0; + if (in_array($row->id, field_available_languages($entity_type, $field))) { + if (!isset($delta_count[$row->entity_id][$row->id])) { + $delta_count[$row->entity_id][$row->id] = 0; } - if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $field['cardinality']) { + if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->id] < $field['cardinality']) { $item = array(); foreach ($field['columns'] as $column => $attributes) { $item[$column] = $row->{$column}; } - $entities[$row->entity_id]->{$field_name}[$row->langcode][] = $item; - $delta_count[$row->entity_id][$row->langcode]++; + $entities[$row->entity_id]->{$field_name}[$row->id][] = $item; + $delta_count[$row->entity_id][$row->id]++; } } } @@ -139,7 +139,7 @@ function field_test_field_storage_write(EntityInterface $entity, $op, $fields) { $langcodes = !empty($entity->$field_name) ? $field_langcodes : $all_langcodes; if ($langcodes) { foreach ($field_data['current'] as $key => $row) { - if ($row->type == $entity->entityType() && $row->entity_id == $id && in_array($row->langcode, $langcodes)) { + if ($row->type == $entity->entityType() && $row->entity_id == $id && in_array($row->id, $langcodes)) { unset($field_data['current'][$key]); } } diff --git a/core/modules/field_sql_storage/field_sql_storage.module b/core/modules/field_sql_storage/field_sql_storage.module index ef8a67f..bf0581e 100644 --- a/core/modules/field_sql_storage/field_sql_storage.module +++ b/core/modules/field_sql_storage/field_sql_storage.module @@ -406,11 +406,11 @@ function field_sql_storage_field_storage_load($entity_type, $entities, $age, $fi $delta_count = array(); foreach ($results as $row) { - if (!isset($delta_count[$row->entity_id][$row->langcode])) { - $delta_count[$row->entity_id][$row->langcode] = 0; + if (!isset($delta_count[$row->entity_id][$row->id])) { + $delta_count[$row->entity_id][$row->id] = 0; } - if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $field['cardinality']) { + if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->id] < $field['cardinality']) { $item = array(); // For each column declared by the field, populate the item // from the prefixed database column. @@ -421,8 +421,8 @@ function field_sql_storage_field_storage_load($entity_type, $entities, $age, $fi } // Add the item to the field values for the entity. - $entities[$row->entity_id]->{$field_name}[$row->langcode][] = $item; - $delta_count[$row->entity_id][$row->langcode]++; + $entities[$row->entity_id]->{$field_name}[$row->id][] = $item; + $delta_count[$row->entity_id][$row->id]++; } } } diff --git a/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php b/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php index 41c9ad1..61c9f85 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php @@ -180,12 +180,12 @@ public static function preCreate(EntityStorageControllerInterface $storage_contr public function preSave(EntityStorageControllerInterface $storage_controller) { $this->timestamp = REQUEST_TIME; $this->setSize(filesize($this->getFileUri())); - if (!isset($this->langcode->value)) { + if (!isset($this->id->value)) { // Default the file's language code to none, because files are language // neutral more often than language dependent. Until we have better // flexible settings. // @todo See http://drupal.org/node/258785 and followups. - $this->langcode = Language::LANGCODE_NOT_SPECIFIED; + $this->id = Language::LANGCODE_NOT_SPECIFIED; } } diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php index 9787554..22fbeb7 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php @@ -57,8 +57,8 @@ function testFileTokenReplacement() { $tests['[file:mime]'] = check_plain($file->getMimeType()); $tests['[file:size]'] = format_size($file->getSize()); $tests['[file:url]'] = check_plain(file_create_url($file->getFileUri())); - $tests['[file:timestamp]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->langcode); - $tests['[file:timestamp:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->langcode); + $tests['[file:timestamp]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->id); + $tests['[file:timestamp:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->id); $tests['[file:owner]'] = check_plain(user_format_name($this->admin_user)); $tests['[file:owner:uid]'] = $file->getOwner()->id(); @@ -66,7 +66,7 @@ function testFileTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized file token %token replaced.', array('%token' => $input))); } @@ -77,7 +77,7 @@ function testFileTokenReplacement() { $tests['[file:size]'] = format_size($file->getSize()); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized file token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/SaveTest.php b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php index 4761105..a7d7134 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SaveTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php @@ -45,12 +45,12 @@ function testFileSave() { $this->assertEqual($loaded_file->isPermanent(), $file->isPermanent(), 'Status was saved correctly.'); $this->assertEqual($file->getSize(), filesize($file->getFileUri()), 'File size was set correctly.', 'File'); $this->assertTrue($file->getChangedTime() > 1, 'File size was set correctly.', 'File'); - $this->assertEqual($loaded_file->langcode->value, Language::LANGCODE_NOT_SPECIFIED, 'Langcode was defaulted correctly.'); + $this->assertEqual($loaded_file->id->value, Language::LANGCODE_NOT_SPECIFIED, 'Langcode was defaulted correctly.'); // Resave the file, updating the existing record. file_test_reset(); $file->status->value = 7; - $file->langcode = 'en'; + $file->id = 'en'; $file->save(); // Check that the correct hooks were called. @@ -61,7 +61,7 @@ function testFileSave() { $loaded_file = file_load($file->id()); $this->assertNotNull($loaded_file, 'Record still exists in the database.', 'File'); $this->assertEqual($loaded_file->isPermanent(), $file->isPermanent(), 'Status was saved correctly.'); - $this->assertEqual($loaded_file->langcode->value, 'en', 'Langcode was saved correctly.'); + $this->assertEqual($loaded_file->id->value, 'en', 'Langcode was saved correctly.'); // Try to insert a second file with the same name apart from case insensitivity // to ensure the 'uri' index allows for filenames with different cases. diff --git a/core/modules/filter/filter.admin.inc b/core/modules/filter/filter.admin.inc index a4493a9..f94b097 100644 --- a/core/modules/filter/filter.admin.inc +++ b/core/modules/filter/filter.admin.inc @@ -172,7 +172,7 @@ function filter_admin_format_form($form, &$form_state, $format) { // @todo Remove once moved to FilterFormatFormController. $form['langcode'] = array( '#type' => 'value', - '#value' => !$format->isNew() ? $format->langcode : language_default()->langcode, + '#value' => !$format->isNew() ? $format->id : language_default()->id, ); // Add user role access selection. diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 1b90cde..f123139 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -272,7 +272,7 @@ function filter_formats($account = NULL) { // All available formats are cached for performance. if (!isset($formats['all'])) { - if ($cache = cache()->get("filter_formats:{$language_interface->langcode}")) { + if ($cache = cache()->get("filter_formats:{$language_interface->id}")) { $formats['all'] = $cache->data; } else { @@ -285,7 +285,7 @@ function filter_formats($account = NULL) { } uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); - cache()->set("filter_formats:{$language_interface->langcode}", $formats['all'], CacheBackendInterface::CACHE_PERMANENT, array('filter_formats' => TRUE)); + cache()->set("filter_formats:{$language_interface->id}", $formats['all'], CacheBackendInterface::CACHE_PERMANENT, array('filter_formats' => TRUE)); } } diff --git a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php index fcf94d8..881cdf7 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php +++ b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php @@ -33,7 +33,7 @@ public function __construct(\Traversable $namespaces) { $annotation_namespaces = array('Drupal\filter\Annotation' => $namespaces['Drupal\filter']); $this->discovery = new AnnotatedClassDiscovery('Filter', $namespaces, $annotation_namespaces, 'Drupal\filter\Annotation\Filter'); $this->discovery = new AlterDecorator($this->discovery, 'filter_info'); - $cache_key = 'filter_plugins:' . language(Language::TYPE_INTERFACE)->langcode; + $cache_key = 'filter_plugins:' . language(Language::TYPE_INTERFACE)->id; $cache_tags = array('filter_formats' => TRUE); $this->discovery = new CacheDecorator($this->discovery, $cache_key, 'cache', CacheBackendInterface::CACHE_PERMANENT, $cache_tags); } diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php index 80b9dd1..820145a 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php @@ -87,7 +87,7 @@ function testTextFormatCrud() { */ function verifyTextFormat($format) { $t_args = array('%format' => $format->name); - $default_langcode = language_default()->langcode; + $default_langcode = language_default()->id; // Verify filter_format_load(). $filter_format = filter_format_load($format->format); @@ -96,7 +96,7 @@ function verifyTextFormat($format) { $this->assertEqual($filter_format->cache, $format->cache, format_string('filter_format_load: Proper cache indicator for text format %format.', $t_args)); $this->assertEqual($filter_format->weight, $format->weight, format_string('filter_format_load: Proper weight for text format %format.', $t_args)); // Check that the filter was created in site default language. - $this->assertEqual($format->langcode, $default_langcode, format_string('filter_format_load: Proper language code for text format %format.', $t_args)); + $this->assertEqual($format->id, $default_langcode, format_string('filter_format_load: Proper language code for text format %format.', $t_args)); // Verify the 'cache' text format property according to enabled filters. $filters = filter_list_format($filter_format->format); diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install index 9f16099..2f18cd6 100644 --- a/core/modules/forum/forum.install +++ b/core/modules/forum/forum.install @@ -38,7 +38,7 @@ function forum_enable() { $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => t('Forums'), 'vid' => 'forums', - 'langcode' => language_default()->langcode, + 'langcode' => language_default()->id, 'description' => t('Forum navigation vocabulary'), 'hierarchy' => 1, 'module' => 'forum', @@ -69,7 +69,7 @@ function forum_enable() { // Create a default forum so forum posts can be created. $term = entity_create('taxonomy_term', array( 'name' => t('General discussion'), - 'langcode' => language_default()->langcode, + 'langcode' => language_default()->id, 'description' => '', 'parent' => array(0), 'vid' => $vocabulary->id(), diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index c28b1dc..33a0b56 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -319,7 +319,7 @@ private function doAdminTests($user) { 'name' => 'Tags', 'description' => $description, 'vid' => 'tags', - 'langcode' => language_default()->langcode, + 'langcode' => language_default()->id, 'help' => $help, )); $vocabulary->save(); diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php index f435de3..725fca3 100644 --- a/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php +++ b/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php @@ -45,8 +45,8 @@ public function normalize($field, $format = NULL, array $context = array()) { // to the field item values. else { foreach ($entity->getTranslationLanguages() as $lang) { - $context['langcode'] = $lang->langcode == 'und' ? Language::LANGCODE_DEFAULT : $lang->langcode; - $translation = $entity->getTranslation($lang->langcode); + $context['langcode'] = $lang->id == 'und' ? Language::LANGCODE_DEFAULT : $lang->id; + $translation = $entity->getTranslation($lang->id); $translated_field = $translation->get($field_name); $normalized_field_items = array_merge($normalized_field_items, $this->normalizeFieldItems($translated_field, $format, $context)); } diff --git a/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php b/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php index 83b4aa6..ea55fd9 100644 --- a/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php +++ b/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php @@ -65,13 +65,13 @@ function setUp() { // Add English as a language. $english = new Language(array( - 'langcode' => 'en', + 'id' => 'en', 'name' => 'English', )); language_save($english); // Add German as a language. $german = new Language(array( - 'langcode' => 'de', + 'id' => 'de', 'name' => 'Deutsch', )); language_save($german); diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 53cb813..6a70e2f 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -836,7 +836,7 @@ function image_effect_definitions() { // hook_image_effect_info() includes translated strings, so each language is // cached separately. - $langcode = $language_interface->langcode; + $langcode = $language_interface->id; $effects = &drupal_static(__FUNCTION__); diff --git a/core/modules/language/config/language.entity.und.yml b/core/modules/language/config/language.entity.und.yml index f0cb10d..e8c4177 100644 --- a/core/modules/language/config/language.entity.und.yml +++ b/core/modules/language/config/language.entity.und.yml @@ -4,4 +4,4 @@ direction: '0' weight: '1' locked: '1' status: '1' -langcode: en +langcode: en \ No newline at end of file diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index ee3dbd1..a7c6663 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -52,7 +52,7 @@ function language_admin_overview_form($form, &$form_state) { 'title' => t('edit'), 'href' => 'admin/config/regional/language/edit/' . $langcode, ); - if ($langcode != $default->langcode) { + if ($langcode != $default->id) { $links['delete'] = array( 'title' => t('delete'), 'href' => 'admin/config/regional/language/delete/' . $langcode, @@ -161,17 +161,17 @@ function language_admin_edit_form($form, &$form_state, $language) { */ function _language_admin_common_controls(&$form, $language = NULL) { if (!is_object($language)) { - $language = new Language(array('langcode' => NULL, 'name' => NULL,)); + $language = new Language(array('id' => NULL, 'name' => NULL,)); } - if (isset($language->langcode)) { + if (isset($language->id)) { $form['langcode_view'] = array( '#type' => 'item', '#title' => t('Language code'), - '#markup' => $language->langcode + '#markup' => $language->id ); $form['langcode'] = array( '#type' => 'value', - '#value' => $language->langcode + '#value' => $language->id ); } else { @@ -245,13 +245,13 @@ function language_admin_add_form_submit($form, &$form_state) { $langcode = $form_state['values']['langcode']; // Custom language form. $language = new Language(array( - 'langcode' => $langcode, + 'id' => $langcode, 'name' => $form_state['values']['name'], 'direction' => $form_state['values']['direction'], )); } else { - $language = new Language(array('langcode' => $langcode)); + $language = new Language(array('id' => $langcode)); } // Save the language and inform the user that it happened. $language = language_save($language); @@ -295,9 +295,9 @@ function language_admin_edit_form_submit($form, &$form_state) { * User interface for the language deletion confirmation screen. */ function language_admin_delete_form($form, &$form_state, $language) { - $langcode = $language->langcode; + $langcode = $language->id; - if (language_default()->langcode == $langcode) { + if (language_default()->id == $langcode) { drupal_set_message(t('The default language cannot be deleted.')); return new RedirectResponse(url('admin/config/regional/language', array('absolute' => TRUE))); } @@ -325,7 +325,7 @@ function language_admin_delete_form_submit($form, &$form_state) { $success = language_delete($langcode); if ($success) { - $t_args = array('%language' => $language->name, '%langcode' => $language->langcode); + $t_args = array('%language' => $language->name, '%langcode' => $language->id); drupal_set_message(t('The %language (%langcode) language has been removed.', $t_args)); } diff --git a/core/modules/language/language.api.php b/core/modules/language/language.api.php index 6f19835..cba3f96 100644 --- a/core/modules/language/language.api.php +++ b/core/modules/language/language.api.php @@ -53,7 +53,7 @@ function hook_language_delete($language) { // On nodes with this language, unset the language db_update('node') ->fields(array('language' => '')) - ->condition('language', $language->langcode) + ->condition('language', $language->id) ->execute(); } diff --git a/core/modules/language/language.install b/core/modules/language/language.install index 9a7ded5..fe83a05 100644 --- a/core/modules/language/language.install +++ b/core/modules/language/language.install @@ -88,8 +88,8 @@ function language_update_8000() { $result = db_query('SELECT * FROM {language}'); $uuid = new Uuid(); foreach ($result as $language) { - config('language.entity.' . $language->langcode) - ->set('id', $language->langcode) + config('language.entity.' . $language->id) + ->set('id', $language->id) ->set('uuid', $uuid->generate()) ->set('label', $language->name) ->set('direction', $language->direction) diff --git a/core/modules/language/language.module b/core/modules/language/language.module index e4af57d..3deb2d4 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -441,11 +441,11 @@ function language_get_default_langcode($entity_type, $bundle) { $language_interface = language(Language::TYPE_INTERFACE); switch ($configuration['langcode']) { case 'site_default': - $default_value = language_default()->langcode; + $default_value = language_default()->id; break; case 'current_interface': - $default_value = $language_interface->langcode; + $default_value = $language_interface->id; break; case 'authors_default': @@ -454,7 +454,7 @@ function language_get_default_langcode($entity_type, $bundle) { $default_value = $user->preferred_langcode; } else { - $default_value = $language_interface->langcode; + $default_value = $language_interface->id; } break; } @@ -475,10 +475,10 @@ function language_get_default_langcode($entity_type, $bundle) { * configuration properties. */ function language_save($language) { - $language_entity = entity_load('language_entity', $language->langcode); + $language_entity = entity_load('language_entity', $language->id); if (!$language_entity) { $language_entity = entity_create('language_entity', array( - 'id' => $language->langcode, + 'id' => $language->id, )); } $language->is_new = $language_entity->isNew(); @@ -494,7 +494,7 @@ function language_save($language) { // Save the record and inform others about the change. $language_entity->save(); - $t_args = array('%language' => $language->name, '%langcode' => $language->langcode); + $t_args = array('%language' => $language->name, '%langcode' => $language->id); if ($language->is_new) { module_invoke_all('language_insert', $language); watchdog('language', 'The %language (%langcode) language has been created.', $t_args); @@ -562,7 +562,7 @@ function language_delete($langcode) { module_invoke_all('language_delete', $language); // Remove the language. - entity_delete_multiple('language_entity', array($language->langcode)); + entity_delete_multiple('language_entity', array($language->id)); language_update_count(); @@ -571,7 +571,7 @@ function language_delete($langcode) { drupal_static_reset('language_list'); - $t_args = array('%language' => $language->name, '%langcode' => $language->langcode); + $t_args = array('%language' => $language->name, '%langcode' => $language->id); watchdog('language', 'The %language (%langcode) language has been removed.', $t_args); return TRUE; } @@ -756,7 +756,7 @@ function language_language_insert($language) { // Add language to the list of language domains. $domains = language_negotiation_url_domains(); - $domains[$language->langcode] = ''; + $domains[$language->id] = ''; language_negotiation_url_domains_save($domains); } @@ -768,12 +768,12 @@ function language_language_delete($language) { // Remove language from language prefix list. $prefixes = language_negotiation_url_prefixes(); - unset($prefixes[$language->langcode]); + unset($prefixes[$language->id]); language_negotiation_url_prefixes_save($prefixes); // Remove language from language domain list. $domains = language_negotiation_url_domains(); - unset($domains[$language->langcode]); + unset($domains[$language->id]); language_negotiation_url_domains_save($domains); } @@ -832,7 +832,7 @@ function language_update_locked_weights() { foreach (language_list(Language::STATE_LOCKED) as $language) { $max_weight++; // Update system languages weight. - config('language.entity.' . $language->langcode) + config('language.entity.' . $language->id) ->set('weight', $max_weight) ->save(); } @@ -852,7 +852,7 @@ function language_form_system_regional_settings_alter(&$form, &$form_state) { $form['locale']['site_default_language'] = array( '#type' => 'select', '#title' => t('Default language'), - '#default_value' => $default->langcode, + '#default_value' => $default->id, '#options' => $language_options, '#description' => t('It is not recommended to change the default language on a working site. Configure the Selected language setting on the detection and selection page to change the fallback language for language selection.', array('@language-detection' => url('admin/config/regional/language/detection'))), '#weight' => -1, diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc index 82bf713..126ec5a 100644 --- a/core/modules/language/language.negotiation.inc +++ b/core/modules/language/language.negotiation.inc @@ -61,7 +61,7 @@ * The current interface language code. */ function language_from_interface() { - return language(Language::TYPE_INTERFACE)->langcode; + return language(Language::TYPE_INTERFACE)->id; } /** @@ -175,7 +175,7 @@ function language_from_browser($languages) { // Find the best match. if ($qvalue > $max_qvalue) { - $best_match_langcode = $language->langcode; + $best_match_langcode = $language->id; $max_qvalue = $qvalue; } } @@ -287,7 +287,7 @@ function language_from_url($languages, Request $request = NULL) { list($language, $path) = language_url_split_prefix($request_path, $languages); if ($language !== FALSE) { - $language_url = $language->langcode; + $language_url = $language->id; } break; @@ -301,13 +301,13 @@ function language_from_url($languages, Request $request = NULL) { $domains = language_negotiation_url_domains(); foreach ($languages as $language) { // Skip the check if the language doesn't have a domain. - if (!empty($domains[$language->langcode])) { + if (!empty($domains[$language->id])) { // Ensure that there is exactly one protocol in the URL when checking // the hostname. - $host = 'http://' . str_replace(array('http://', 'https://'), '', $domains[$language->langcode]); + $host = 'http://' . str_replace(array('http://', 'https://'), '', $domains[$language->id]); $host = parse_url($host, PHP_URL_HOST); if ($http_host == $host) { - $language_url = $language->langcode; + $language_url = $language->id; break; } } @@ -363,11 +363,11 @@ function language_url_fallback($language = NULL, $request = NULL, $language_type // the default one, otherwise we fall back to an already detected language. $domains = language_negotiation_url_domains(); $prefixes = language_negotiation_url_prefixes(); - if (($prefix && empty($prefixes[$default->langcode])) || (!$prefix && empty($domains[$default->langcode]))) { - return $default->langcode; + if (($prefix && empty($prefixes[$default->id])) || (!$prefix && empty($domains[$default->id]))) { + return $default->id; } else { - $langcode = language($language_type)->langcode; + $langcode = language($language_type)->id; return $langcode; } } @@ -382,7 +382,7 @@ function language_switcher_url($type, $path) { $links = array(); foreach ($languages as $language) { - $links[$language->langcode] = array( + $links[$language->id] = array( 'href' => $path, 'title' => $language->name, 'language' => $language, @@ -398,7 +398,7 @@ function language_switcher_url($type, $path) { */ function language_switcher_session($type, $path) { $param = config('language.negotiation')->get('session.parameter'); - $language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : language($type)->langcode; + $language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : language($type)->id; $languages = language_list(); $links = array(); @@ -406,7 +406,7 @@ function language_switcher_session($type, $path) { $query = $_GET; foreach ($languages as $language) { - $langcode = $language->langcode; + $langcode = $language->id; $links[$langcode] = array( 'href' => $path, 'title' => $language->name, @@ -439,10 +439,10 @@ function language_negotiation_url_prefixes_update() { foreach (language_list() as $language) { // The prefix for this language should be updated if it's not assigned yet // or the prefix is set to the empty string. - if (empty($prefixes[$language->langcode])) { + if (empty($prefixes[$language->id])) { // For the default language, set the prefix to the empty string, // otherwise use the langcode. - $prefixes[$language->langcode] = !empty($language->default) ? '' : $language->langcode; + $prefixes[$language->id] = !empty($language->default) ? '' : $language->id; } // Otherwise we keep the configured prefix. } diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php index 9a95329..e73ccdb 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php @@ -70,7 +70,7 @@ public function buildForm(array $form, array &$form_state) { $prefixes = language_negotiation_url_prefixes(); $domains = language_negotiation_url_domains(); foreach ($languages as $langcode => $language) { - $t_args = array('%language' => $language->name, '%langcode' => $language->langcode); + $t_args = array('%language' => $language->name, '%langcode' => $language->id); $form['prefix'][$langcode] = array( '#type' => 'textfield', '#title' => $language->default ? t('%language (%langcode) path prefix (Default language)', $t_args) : t('%language (%langcode) path prefix', $t_args), @@ -80,7 +80,7 @@ public function buildForm(array $form, array &$form_state) { ); $form['domain'][$langcode] = array( '#type' => 'textfield', - '#title' => t('%language (%langcode) domain', array('%language' => $language->name, '%langcode' => $language->langcode)), + '#title' => t('%language (%langcode) domain', array('%language' => $language->name, '%langcode' => $language->id)), '#maxlength' => 128, '#default_value' => isset($domains[$langcode]) ? $domains[$langcode] : '', ); diff --git a/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php b/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php index 2440d2f..aa3cc2b 100644 --- a/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php +++ b/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php @@ -81,7 +81,7 @@ public function processInbound($path, Request $request) { // Search prefix within enabled languages. $prefixes = $this->config->get('language.negotiation')->get('url.prefixes'); foreach ($this->languages as $language) { - if (isset($prefixes[$language->langcode]) && $prefixes[$language->langcode] == $prefix) { + if (isset($prefixes[$language->id]) && $prefixes[$language->id] == $prefix) { // Rebuild $path with the language removed. return implode('/', $args); } @@ -110,7 +110,7 @@ public function processOutbound($path, &$options = array(), Request $request = N $options['language'] = $language_url; } // We allow only enabled languages here. - elseif (is_object($options['language']) && !isset($languages[$options['language']->langcode])) { + elseif (is_object($options['language']) && !isset($languages[$options['language']->id])) { return $path; } $url_source = $this->config->get('language.negotiation')->get('url.source'); @@ -118,13 +118,13 @@ public function processOutbound($path, &$options = array(), Request $request = N // constant. if ($url_source == 'path_prefix') { $prefixes = $this->config->get('language.negotiation')->get('url.prefixes'); - if (is_object($options['language']) && !empty($prefixes[$options['language']->langcode])) { - return empty($path) ? $prefixes[$options['language']->langcode] : $prefixes[$options['language']->langcode] . '/' . $path; + if (is_object($options['language']) && !empty($prefixes[$options['language']->id])) { + return empty($path) ? $prefixes[$options['language']->id] : $prefixes[$options['language']->id] . '/' . $path; } } elseif ($url_source == 'domain') { $domains = $this->config->get('language.negotiation')->get('url.domains'); - if (is_object($options['language']) && !empty($domains[$options['language']->langcode])) { + if (is_object($options['language']) && !empty($domains[$options['language']->id])) { // Save the original base URL. If it contains a port, we need to // retain it below. @@ -135,7 +135,7 @@ public function processOutbound($path, &$options = array(), Request $request = N // Ask for an absolute URL with our modified base URL. $options['absolute'] = TRUE; - $options['base_url'] = $url_scheme . '://' . $domains[$options['language']->langcode]; + $options['base_url'] = $url_scheme . '://' . $domains[$options['language']->id]; // In case either the original base URL or the HTTP host contains a // port, retain it. diff --git a/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php b/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php index fdf9275..9511f2e 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php +++ b/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php @@ -39,7 +39,7 @@ public function buildForm(array $form, array &$form_state) { foreach ($languages as $language) { // @todo $language->name is not wrapped with t(), it should be replaced // by CMI translation implementation. - $langcodes_options[$language->langcode] = $language->name; + $langcodes_options[$language->id] = $language->name; } $form['langcodes'] = array( '#type' => 'checkboxes', @@ -76,8 +76,8 @@ public function summary() { $language_names = array_reduce($language_list, function(&$result, $item) use ($selected) { // If the current item of the $language_list array is one of the selected // languages, add it to the $results array. - if (!empty($selected[$item->langcode])) { - $result[$item->langcode] = $item->name; + if (!empty($selected[$item->id])) { + $result[$item->id] = $item->name; } return $result; }, array()); @@ -103,7 +103,7 @@ public function evaluate() { $language = $this->getContextValue('language'); // Language visibility settings. if (!empty($this->configuration['langcodes'])) { - return !empty($this->configuration['langcodes'][$language->langcode]); + return !empty($this->configuration['langcodes'][$language->id]); } return TRUE; } diff --git a/core/modules/language/lib/Drupal/language/Tests/Condition/LanguageConditionTest.php b/core/modules/language/lib/Drupal/language/Tests/Condition/LanguageConditionTest.php index 52c3b92..19449d8 100644 --- a/core/modules/language/lib/Drupal/language/Tests/Condition/LanguageConditionTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/Condition/LanguageConditionTest.php @@ -58,7 +58,7 @@ protected function setUp() { // Setup Italian. $language = new Language(array( - 'langcode' => 'it', + 'id' => 'it', 'name' => 'Italian', 'direction' => '0', )); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php index 80a835d..07ea3d5 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php @@ -39,40 +39,40 @@ function testLanguageFromBrowser() { $languages = array( // In our test case, 'en' has priority over 'en-US'. 'en' => new Language(array( - 'langcode' => 'en', + 'id' => 'en', )), 'en-US' => new Language(array( - 'langcode' => 'en-US', + 'id' => 'en-US', )), // But 'fr-CA' has priority over 'fr'. 'fr-CA' => new Language(array( - 'langcode' => 'fr-CA', + 'id' => 'fr-CA', )), 'fr' => new Language(array( - 'langcode' => 'fr', + 'id' => 'fr', )), // 'es-MX' is alone. 'es-MX' => new Language(array( - 'langcode' => 'es-MX', + 'id' => 'es-MX', )), // 'pt' is alone. 'pt' => new Language(array( - 'langcode' => 'pt', + 'id' => 'pt', )), // Language codes with more then one dash are actually valid. // eh-oh-laa-laa is the official language code of the Teletubbies. 'eh-oh-laa-laa' => new Language(array( - 'langcode' => 'eh-oh-laa-laa', + 'id' => 'eh-oh-laa-laa', )), // Chinese languages. 'zh-hans' => new Language(array( - 'langcode' => 'zh-hans', + 'id' => 'zh-hans', )), 'zh-hant' => new Language(array( - 'langcode' => 'zh-hant', + 'id' => 'zh-hant', )), 'zh-hant-tw' => new Language(array( - 'langcode' => 'zh-hant', + 'id' => 'zh-hant', )), ); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php index 1bc67da..fcec194 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php @@ -69,7 +69,7 @@ public function testDefaultLangcode() { // Add some custom languages. foreach (array('aa', 'bb', 'cc') as $language_code) { $language = new Language(array( - 'langcode' => $language_code, + 'id' => $language_code, 'name' => $this->randomName(), )); language_save($language); @@ -84,7 +84,7 @@ public function testDefaultLangcode() { language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'current_interface', 'language_show' => TRUE)); $langcode = language_get_default_langcode('custom_type', 'custom_bundle'); $language_interface = language(Language::TYPE_INTERFACE); - $this->assertEqual($langcode, $language_interface->langcode); + $this->assertEqual($langcode, $language_interface->id); // Site's default. $old_default = language_default(); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php index 4bce384..6e85b1e 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php @@ -146,6 +146,7 @@ protected function checkConfigurableLanguageWeight($state = 'by default') { drupal_static_reset('language_list'); $max_configurable_language_weight = $this->getHighestConfigurableLanguageWeight(); $replacements = array('@event' => $state); + debug(language_list(Language::STATE_ALL)); foreach (language_list(Language::STATE_LOCKED) as $locked_language) { $replacements['%language'] = $locked_language->name; $this->assertTrue($locked_language->weight > $max_configurable_language_weight, format_string('System language %language has higher weight than configurable languages @event', $replacements)); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php index 088d655..97488ed 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php @@ -64,7 +64,7 @@ function testDependencyInjectedNewLanguage() { function testDependencyInjectedNewDefaultLanguage() { // Change the language default object to different values. $new_language_default = array( - 'langcode' => 'fr', + 'id' => 'fr', 'name' => 'French', 'direction' => 0, 'weight' => 0, diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php index 570ae2a..fa718da 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php @@ -173,10 +173,10 @@ function testLanguageList() { */ function testLanguageStates() { // Add some languages, and also lock some of them. - language_save(new Language(array('name' => $this->randomName(), 'langcode' => 'l1'))); - language_save(new Language(array('name' => $this->randomName(), 'langcode' => 'l2', 'locked' => TRUE))); - language_save(new Language(array('name' => $this->randomName(), 'langcode' => 'l3'))); - language_save(new Language(array('name' => $this->randomName(), 'langcode' => 'l4', 'locked' => TRUE))); + language_save(new Language(array('name' => $this->randomName(), 'id' => 'l1'))); + language_save(new Language(array('name' => $this->randomName(), 'id' => 'l2', 'locked' => TRUE))); + language_save(new Language(array('name' => $this->randomName(), 'id' => 'l3'))); + language_save(new Language(array('name' => $this->randomName(), 'id' => 'l4', 'locked' => TRUE))); $expected_locked_languages = array('l4' => 'l4', 'l2' => 'l2', 'und' => 'und', 'zxx' => 'zxx'); $expected_all_languages = array('l4' => 'l4', 'l3' => 'l3', 'l2' => 'l2', 'l1' => 'l1', 'en' => 'en', 'und' => 'und', 'zxx' => 'zxx'); $expected_conf_languages = array('l3' => 'l3', 'l1' => 'l1', 'en' => 'en'); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php index 89a1bd6..d7f0306 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php @@ -52,7 +52,7 @@ function setUp() { // Verify that French is the only language. $this->assertFalse(language_multilingual(), 'Site is mono-lingual'); - $this->assertEqual(language_default()->langcode, 'fr', 'French is the default language'); + $this->assertEqual(language_default()->id, 'fr', 'French is the default language'); // Set language detection to URL. $edit = array('language_interface[enabled][language-url]' => TRUE); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php index c9c05e8..2884013 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php @@ -90,11 +90,11 @@ function testUILanguageNegotiation() { // Setup the site languages by installing two languages. $language = new Language(array( - 'langcode' => $langcode_browser_fallback, + 'id' => $langcode_browser_fallback, )); language_save($language); $language = new Language(array( - 'langcode' => $langcode, + 'id' => $langcode, )); language_save($language); @@ -387,7 +387,7 @@ function testUrlLanguageFallback() { // Add the Italian language. $langcode_browser_fallback = 'it'; $language = new Language(array( - 'langcode' => $langcode_browser_fallback, + 'id' => $langcode_browser_fallback, )); language_save($language); $languages = language_list(); @@ -434,7 +434,7 @@ function testLanguageDomain() { // Add the Italian language. $langcode = 'it'; $language = new Language(array( - 'langcode' => $langcode, + 'id' => $langcode, )); language_save($language); $languages = language_list(); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php index 7801959..486c631 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php @@ -56,7 +56,7 @@ function setUp() { function testUrlRewritingEdgeCases() { // Check URL rewriting with a non-installed language. $non_existing = language_default(); - $non_existing->langcode = $this->randomName(); + $non_existing->id = $this->randomName(); $this->checkUrl($non_existing, 'Path language is ignored if language is not installed.', 'URL language negotiation does not work with non-installed languages'); $request = $this->prepareRequestForGenerator(); @@ -90,7 +90,7 @@ private function checkUrl($language, $message1, $message2) { // If the rewritten URL has not a language prefix we pick a random prefix so // we can always check the prefixed URL. $prefixes = language_negotiation_url_prefixes(); - $stored_prefix = isset($prefixes[$language->langcode]) ? $prefixes[$language->langcode] : $this->randomName(); + $stored_prefix = isset($prefixes[$language->id]) ? $prefixes[$language->id] : $this->randomName(); if ($this->assertNotEqual($stored_prefix, $prefix, $message1)) { $prefix = $stored_prefix; } diff --git a/core/modules/language/lib/Drupal/language/Tests/Views/LanguageTestBase.php b/core/modules/language/lib/Drupal/language/Tests/Views/LanguageTestBase.php index 9bc79dd..3a8feed 100644 --- a/core/modules/language/lib/Drupal/language/Tests/Views/LanguageTestBase.php +++ b/core/modules/language/lib/Drupal/language/Tests/Views/LanguageTestBase.php @@ -28,9 +28,9 @@ protected function setUp() { $this->installConfig(array('language')); // Create English and another language beside English. - $language = new Language(array('langcode' => 'en')); + $language = new Language(array('id' => 'en')); language_save($language); - $language = new Language(array('langcode' => 'xx-lolspeak', 'name' => 'Lolspeak')); + $language = new Language(array('id' => 'xx-lolspeak', 'name' => 'Lolspeak')); language_save($language); } diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index e1fd17d..3cb6f6b 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -15,7 +15,7 @@ */ function language_test_page_build() { language_test_store_language_negotiation(); - if (isset(language(Language::TYPE_INTERFACE)->langcode) && isset(language(Language::TYPE_INTERFACE)->method_id)) { + if (isset(language(Language::TYPE_INTERFACE)->id) && isset(language(Language::TYPE_INTERFACE)->method_id)) { drupal_set_message(t('Language negotiation method: @name', array('@name' => language(Language::TYPE_INTERFACE)->method_id))); } } @@ -88,7 +88,7 @@ function language_test_language_negotiation_info_alter(array &$negotiation_info) function language_test_store_language_negotiation() { $last = array(); foreach (language_types_get_all() as $type) { - $last[$type] = language($type)->langcode; + $last[$type] = language($type)->id; } Drupal::state()->set('language_test.language_negotiation_last', $last); } diff --git a/core/modules/locale/lib/Drupal/locale/Gettext.php b/core/modules/locale/lib/Drupal/locale/Gettext.php index f9f9129..3334323 100644 --- a/core/modules/locale/lib/Drupal/locale/Gettext.php +++ b/core/modules/locale/lib/Drupal/locale/Gettext.php @@ -56,7 +56,7 @@ static function fileToDatabase($file, $options) { ); // Instantiate and initialize the stream reader for this file. $reader = new PoStreamReader(); - $reader->setLangcode($file->langcode); + $reader->setLangcode($file->id); $reader->setURI($file->uri); try { @@ -73,7 +73,7 @@ static function fileToDatabase($file, $options) { // Initialize the database writer. $writer = new PoDatabaseWriter(); - $writer->setLangcode($file->langcode); + $writer->setLangcode($file->id); $writer_options = array( 'overwrite_options' => $options['overwrite_options'], 'customized' => $options['customized'], diff --git a/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php b/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php index b1aa4b2..7b1219b 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php @@ -125,7 +125,7 @@ public function onKernelRequestSetDefaultConfigContextLocale(GetResponseEvent $e * The localized config name. */ public function getLocaleConfigName($name, Language $language) { - return 'locale.config.' . $language->langcode . '.' . $name; + return 'locale.config.' . $language->id . '.' . $name; } /** diff --git a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php index e86edbf..372a01f 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php @@ -67,7 +67,7 @@ class LocaleLookup extends CacheCollector { * The lock backend. */ public function __construct($langcode, $context, StringStorageInterface $string_storage, CacheBackendInterface $cache, LockBackendInterface $lock) { - $this->langcode = $langcode; + $this->id = $langcode; $this->context = (string) $context; $this->stringStorage = $string_storage; @@ -83,7 +83,7 @@ public function __construct($langcode, $context, StringStorageInterface $string_ */ protected function resolveCacheMiss($offset) { $translation = $this->stringStorage->findTranslation(array( - 'language' => $this->langcode, + 'language' => $this->id, 'source' => $offset, 'context' => $this->context, )); diff --git a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php index 5d6b200..f67131a 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php @@ -52,7 +52,7 @@ class LocaleTypedConfig extends Element { */ public function __construct(array $definition, $name, $langcode, \Drupal\locale\LocaleConfigManager $localeConfig) { parent::__construct($definition, $name); - $this->langcode = $langcode; + $this->id = $langcode; $this->localeConfig = $localeConfig; } @@ -68,7 +68,7 @@ public function getTypedConfig() { */ public function getTranslation($langcode) { $options = array( - 'source' => $this->langcode, + 'source' => $this->id, 'target' => $langcode, ); $data = $this->getElementTranslation($this->getTypedConfig(), $options); @@ -79,7 +79,7 @@ public function getTranslation($langcode) { * {@inheritdoc} */ public function language() { - return language_load($this->langcode); + return language_load($this->id); } /** diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php index 37b796c..4701645 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php @@ -48,7 +48,7 @@ function setUp() { $this->storage = $this->container->get('locale.storage'); // Create two languages: Spanish and German. foreach (array('es', 'de') as $langcode) { - $language = new Language(array('langcode' => $langcode)); + $language = new Language(array('id' => $langcode)); $languages[$langcode] = language_save($language); } } @@ -180,7 +180,7 @@ function buildSourceString($values = array()) { function createAllTranslations($source, $values = array()) { $list = array(); foreach (language_list() as $language) { - $list[$language->langcode] = $this->createTranslation($source, $language->langcode, $values); + $list[$language->id] = $this->createTranslation($source, $language->id, $values); } return $list; } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php index d2f1579..63ef579 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php @@ -480,7 +480,7 @@ function testStringSearch() { function testUICustomizedStrings(){ $user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages')); $this->drupalLogin($user); - $language = new Language(array('langcode' => 'de')); + $language = new Language(array('id' => 'de')); language_save($language); // Create test source string diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallFrenchTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallFrenchTest.php index 047ff63..6cd9f3c 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallFrenchTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallFrenchTest.php @@ -26,6 +26,6 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->langcode = 'fr'; + $this->id = 'fr'; } } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php index 5675229..386d899 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php @@ -38,7 +38,7 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->langcode = 'en'; + $this->id = 'en'; // Create Article node type. $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); @@ -51,9 +51,9 @@ function testUninstallProcess() { $locale_module = array('locale', 'language'); $config = config('locale.settings'); $language = new Language(array( - 'langcode' => 'fr', + 'id' => 'fr', 'name' => 'French', - 'default' => $this->langcode == 'fr', + 'default' => $this->id == 'fr', )); language_save($language); // Reset the language manager. @@ -68,7 +68,7 @@ function testUninstallProcess() { global $user; $user = drupal_anonymous_user(); - $this->assertEqual(language(Language::TYPE_INTERFACE)->langcode, $this->langcode, t('Current language: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->langcode))); + $this->assertEqual(language(Language::TYPE_INTERFACE)->id, $this->id, t('Current language: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->id))); // Enable multilingual workflow option for articles. language_save_default_configuration('node', 'article', array('langcode' => 'site_default', 'language_show' => TRUE)); @@ -115,7 +115,7 @@ function testUninstallProcess() { // Visit the front page. $this->drupalGet(''); // Check the init language logic. - $this->assertEqual(language(Language::TYPE_INTERFACE)->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->langcode))); + $this->assertEqual(language(Language::TYPE_INTERFACE)->id, 'en', t('Language after uninstall: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->id))); // Check JavaScript files deletion. $this->assertTrue($result = !file_exists($js_file), t('JavaScript file deleted: %file', array('%file' => $result ? $js_file : t('found')))); diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc index 352b0a5..4b5742b 100644 --- a/core/modules/locale/locale.batch.inc +++ b/core/modules/locale/locale.batch.inc @@ -55,7 +55,7 @@ function locale_translation_batch_status_fetch_remote($source, &$context) { // reporting at the end of the batch. $context['results']['failed_files'][] = $source->name; } - $context['results']['sources'][$source->name][$source->langcode] = $source; + $context['results']['sources'][$source->name][$source->id] = $source; $context['message'] = t('Checked translation for %project.', array('%project' => $source->project)); } } @@ -85,13 +85,13 @@ function locale_translation_batch_status_fetch_local($sources, &$context) { // If remote data was collected before, we merge it into the newly // collected result. - if (isset($context['results']['sources'][$source->name][$source->langcode])) { - $source->files[LOCALE_TRANSLATION_REMOTE] = $context['results']['sources'][$source->name][$source->langcode]->files[LOCALE_TRANSLATION_REMOTE]; + if (isset($context['results']['sources'][$source->name][$source->id])) { + $source->files[LOCALE_TRANSLATION_REMOTE] = $context['results']['sources'][$source->name][$source->id]->files[LOCALE_TRANSLATION_REMOTE]; } // Record success and store the updated source data. $context['results']['files'][$source->name] = $source->name; - $context['results']['sources'][$source->name][$source->langcode] = $source; + $context['results']['sources'][$source->name][$source->id] = $source; } } $context['message'] = t('Checked all translations.'); @@ -135,8 +135,8 @@ function locale_translation_batch_status_compare(&$context) { // status. If the project/language was translated before and it is more // recent than the most recent translation, the translation is up to // date. Which is marked in the source object with type "current". - if (isset($history[$source->project][$source->langcode])) { - $current = $history[$source->project][$source->langcode]; + if (isset($history[$source->project][$source->id])) { + $current = $history[$source->project][$source->id]; // Add the current translation to the source object to save it in // the status cache. $source->files[LOCALE_TRANSLATION_CURRENT] = $current; @@ -293,9 +293,9 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$ // If we are working on a remote file we will import the downloaded // file. If the file was local just mark the result as such. if ($source->type == LOCALE_TRANSLATION_REMOTE) { - if (isset($context['results']['sources'][$source->project][$source->langcode]->files[LOCALE_TRANSLATION_DOWNLOADED])) { + if (isset($context['results']['sources'][$source->project][$source->id]->files[LOCALE_TRANSLATION_DOWNLOADED])) { $import_type = LOCALE_TRANSLATION_DOWNLOADED; - $source_result = $context['results']['sources'][$source->project][$source->langcode]; + $source_result = $context['results']['sources'][$source->project][$source->id]; } } else { @@ -359,7 +359,7 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$ } } } - $context['results']['sources'][$source->project][$source->langcode] = $source_result; + $context['results']['sources'][$source->project][$source->id] = $source_result; } } } @@ -497,7 +497,7 @@ function locale_translation_download_source($source_file) { if ($uri = system_retrieve_file($source_file->uri, 'temporary://')) { $file = new stdClass(); $file->project = $source_file->project; - $file->langcode = $source_file->langcode; + $file->id = $source_file->id; $file->version = $source_file->version; $file->type = LOCALE_TRANSLATION_DOWNLOADED; $file->uri = $uri; diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index a59c464..4ba6ca30 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -115,7 +115,7 @@ function locale_translate_import_form_submit($form, &$form_state) { $language = language_load($form_state['values']['langcode']); if (empty($language)) { $language = new Language(array( - 'langcode' => $form_state['values']['langcode'] + 'id' => $form_state['values']['langcode'] )); $language = language_save($language); drupal_set_message(t('The language %language has been created.', array('%language' => t($language->name)))); @@ -171,7 +171,7 @@ function locale_translate_export_form($form, &$form_state) { '#type' => 'select', '#title' => t('Language'), '#options' => $language_options, - '#default_value' => $language_default->langcode, + '#default_value' => $language_default->id, '#empty_option' => t('Source text only, no translations'), '#empty_value' => Language::LANGCODE_SYSTEM, ); @@ -228,11 +228,11 @@ function locale_translate_export_form_submit($form, &$form_state) { $reader = new PoDatabaseReader(); $languageName = ''; if ($language != NULL) { - $reader->setLangcode($language->langcode); + $reader->setLangcode($language->id); $reader->setOptions($content_options); $languages = language_list(); - $languageName = isset($languages[$language->langcode]) ? $languages[$language->langcode]->name : ''; - $filename = $language->langcode .'.po'; + $languageName = isset($languages[$language->id]) ? $languages[$language->id]->name : ''; + $filename = $language->id .'.po'; } else { // Template required. @@ -355,7 +355,7 @@ function locale_translate_get_interface_translation_files($projects = array(), $ // Update the file object with project name and version from the file name. $file = locale_translate_file_attach_properties($file); if (in_array($file->project, $projects)) { - if (in_array($file->langcode, $langcodes)) { + if (in_array($file->id, $langcodes)) { $files[$file->uri] = $file; } } @@ -449,7 +449,7 @@ function locale_translate_batch_import($file, $options, &$context) { 'customized' => LOCALE_NOT_CUSTOMIZED, ); - if (isset($file->langcode) && $file->langcode != Language::LANGCODE_NOT_SPECIFIED) { + if (isset($file->id) && $file->id != Language::LANGCODE_NOT_SPECIFIED) { try { if (empty($context['sandbox'])) { @@ -487,7 +487,7 @@ function locale_translate_batch_import($file, $options, &$context) { // Store the file data for processing by the next batch operation. $file->timestamp = filemtime($file->uri); $context['results']['files'][$file->uri] = $file; - $context['results']['languages'][$file->uri] = $file->langcode; + $context['results']['languages'][$file->uri] = $file->id; } // Add the reported values to the statistics for this file. @@ -713,10 +713,10 @@ function locale_translate_file_attach_properties($file, $options = array()) { if (isset($matches[5])) { $file->project = $matches[2] . $matches[3]; $file->version = $matches[4]; - $file->langcode = isset($options['langcode']) ? $options['langcode'] : $matches[5]; + $file->id = isset($options['langcode']) ? $options['langcode'] : $matches[5]; } else { - $file->langcode = Language::LANGCODE_NOT_SPECIFIED; + $file->id = Language::LANGCODE_NOT_SPECIFIED; } return $file; } diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc index 66411d8..3609e5a 100644 --- a/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -226,7 +226,7 @@ function locale_translation_build_server_pattern($project, $template) { '%project' => $project->name, '%version' => $project->version, '%core' => $project->core, - '%language' => isset($project->langcode) ? $project->langcode : '%language', + '%language' => isset($project->id) ? $project->id : '%language', ); return strtr($template, $variables); } @@ -380,8 +380,8 @@ function locale_translation_check_projects_local($projects = array(), $langcodes // If the project/language was translated before and it is more recent // than the most recent translation, the translation is up to date. Which // is marked in the source object with type "current". - if (isset($history[$source->project][$source->langcode])) { - $current = $history[$source->project][$source->langcode]; + if (isset($history[$source->project][$source->id])) { + $current = $history[$source->project][$source->id]; // Add the current translation to the source object to save it in // the status cache. $source->files[LOCALE_TRANSLATION_CURRENT] = $current; diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index dcca8bf..c05579f 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -292,7 +292,7 @@ function locale_language_insert($language) { // Changing the language settings impacts the interface. cache('page')->deleteAll(); // Force JavaScript translation file re-creation for the new language. - _locale_invalidate_js($language->langcode); + _locale_invalidate_js($language->id); } /** @@ -303,7 +303,7 @@ function locale_language_update($language) { // Changing the language settings impacts the interface. cache('page')->deleteAll(); // Force JavaScript translation file re-creation for the modified language. - _locale_invalidate_js($language->langcode); + _locale_invalidate_js($language->id); } /** @@ -311,22 +311,22 @@ function locale_language_update($language) { */ function locale_language_delete($language) { // Remove translations. - Drupal::service('locale.storage')->deleteTranslations(array('language' => $language->langcode)); + Drupal::service('locale.storage')->deleteTranslations(array('language' => $language->id)); // Remove interface translation files. module_load_include('inc', 'locale', 'locale.bulk'); - locale_translate_delete_translation_files(array(), array($language->langcode)); + locale_translate_delete_translation_files(array(), array($language->id)); // Remove translated configuration objects. - \Drupal\locale\Locale::config()->deleteLanguageTranslations($language->langcode); + \Drupal\locale\Locale::config()->deleteLanguageTranslations($language->id); // Changing the language settings impacts the interface: - _locale_invalidate_js($language->langcode); + _locale_invalidate_js($language->id); cache('page')->deleteAll(); // Clear locale translation caches. - locale_translation_status_delete_languages(array($language->langcode)); - cache()->delete('locale:' . $language->langcode); + locale_translation_status_delete_languages(array($language->id)); + cache()->delete('locale:' . $language->id); } /** @@ -368,7 +368,7 @@ function locale_get_plural($count, $langcode = NULL) { // individually for each language. $plural_indexes = &drupal_static(__FUNCTION__ . ':plurals', array()); - $langcode = $langcode ? $langcode : $language_interface->langcode; + $langcode = $langcode ? $langcode : $language_interface->id; if (!isset($plural_indexes[$langcode][$count])) { // Retrieve and statically cache the plural formulas for all languages. @@ -553,11 +553,11 @@ function locale_js_alter(&$javascript) { } // If necessary, rebuild the translation file for the current language. - if (!empty($parsed['refresh:' . $language_interface->langcode])) { + if (!empty($parsed['refresh:' . $language_interface->id])) { // Don't clear the refresh flag on failure, so that another try will // be performed later. if (_locale_rebuild_js()) { - unset($parsed['refresh:' . $language_interface->langcode]); + unset($parsed['refresh:' . $language_interface->id]); } // Store any changes after refresh was attempted. Drupal::state()->set('system.javascript_parsed', $parsed); @@ -570,9 +570,9 @@ function locale_js_alter(&$javascript) { // Add the translation JavaScript file to the page. $locale_javascripts = Drupal::state()->get('translation.javascript') ?: array(); - if ($files && !empty($locale_javascripts[$language_interface->langcode])) { + if ($files && !empty($locale_javascripts[$language_interface->id])) { // Add the translation JavaScript file to the page. - $file = $dir . '/' . $language_interface->langcode . '_' . $locale_javascripts[$language_interface->langcode] . '.js'; + $file = $dir . '/' . $language_interface->id . '_' . $locale_javascripts[$language_interface->id] . '.js'; $javascript[$file] = drupal_js_defaults($file); } } @@ -797,15 +797,15 @@ function locale_system_file_system_settings_submit(&$form, $form_state) { * Implements hook_preprocess_HOOK() for node.html.twig. */ function locale_preprocess_node(&$variables) { - if ($variables['node']->langcode != Language::LANGCODE_NOT_SPECIFIED) { + if ($variables['node']->id != Language::LANGCODE_NOT_SPECIFIED) { $language_interface = language(Language::TYPE_INTERFACE); - $node_language = language_load($variables['node']->langcode); - if ($node_language->langcode != $language_interface->langcode) { + $node_language = language_load($variables['node']->id); + if ($node_language->id != $language_interface->id) { // If the node language was different from the page language, we should // add markup to identify the language. Otherwise the page language is // inherited. - $variables['attributes']['lang'] = $variables['node']->langcode; + $variables['attributes']['lang'] = $variables['node']->id; if ($node_language->direction != $language_interface->direction) { // If text direction is different form the page's text direction, add // direction information as well. @@ -830,7 +830,7 @@ function locale_translation_get_file_history() { $result = db_query('SELECT project, langcode, filename, version, uri, timestamp, last_checked FROM {locale_file}'); foreach ($result as $file) { $file->type = LOCALE_TRANSLATION_CURRENT; - $history[$file->project][$file->langcode] = $file; + $history[$file->project][$file->id] = $file; } } return $history; @@ -849,7 +849,7 @@ function locale_translation_get_file_history() { */ function locale_translation_update_file_history($file) { // Update or write new record. - if (db_query("SELECT project FROM {locale_file} WHERE project = :project AND langcode = :langcode", array(':project' => $file->project, ':langcode' => $file->langcode))->fetchField()) { + if (db_query("SELECT project FROM {locale_file} WHERE project = :project AND langcode = :langcode", array(':project' => $file->project, ':langcode' => $file->id))->fetchField()) { $update = array('project', 'langcode'); } else { @@ -1181,7 +1181,7 @@ function _locale_rebuild_js($langcode = NULL) { // Only add strings with a translation to the translations array. $conditions = array( 'type' => 'javascript', - 'language' => $language->langcode, + 'language' => $language->id, 'translated' => TRUE, ); $translations = array(); @@ -1196,8 +1196,8 @@ function _locale_rebuild_js($langcode = NULL) { $data = "Drupal.locale = { "; $locale_plurals = Drupal::state()->get('locale.translation.plurals') ?: array(); - if (!empty($locale_plurals[$language->langcode])) { - $data .= "'pluralFormula': function (\$n) { return Number({$locale_plurals[$language->langcode]['formula']}); }, "; + if (!empty($locale_plurals[$language->id])) { + $data .= "'pluralFormula': function (\$n) { return Number({$locale_plurals[$language->id]['formula']}); }, "; } $data .= "'strings': " . drupal_json_encode($translations) . " };"; @@ -1210,23 +1210,23 @@ function _locale_rebuild_js($langcode = NULL) { // Delete old file, if we have no translations anymore, or a different file to be saved. $locale_javascripts = Drupal::state()->get('locale.translation.javascript') ?: array(); - $changed_hash = !isset($locale_javascripts[$language->langcode]) || ($locale_javascripts[$language->langcode] != $data_hash); - if (!empty($locale_javascripts[$language->langcode]) && (!$data || $changed_hash)) { - file_unmanaged_delete($dir . '/' . $language->langcode . '_' . $locale_javascripts[$language->langcode] . '.js'); - $locale_javascripts[$language->langcode] = ''; + $changed_hash = !isset($locale_javascripts[$language->id]) || ($locale_javascripts[$language->id] != $data_hash); + if (!empty($locale_javascripts[$language->id]) && (!$data || $changed_hash)) { + file_unmanaged_delete($dir . '/' . $language->id . '_' . $locale_javascripts[$language->id] . '.js'); + $locale_javascripts[$language->id] = ''; $status = 'deleted'; } // Only create a new file if the content has changed or the original file got // lost. - $dest = $dir . '/' . $language->langcode . '_' . $data_hash . '.js'; + $dest = $dir . '/' . $language->id . '_' . $data_hash . '.js'; if ($data && ($changed_hash || !file_exists($dest))) { // Ensure that the directory exists and is writable, if possible. file_prepare_directory($dir, FILE_CREATE_DIRECTORY); // Save the file. if (file_unmanaged_save_data($data, $dest)) { - $locale_javascripts[$language->langcode] = $data_hash; + $locale_javascripts[$language->id] = $data_hash; // If we deleted a previous version of the file and we replace it with a // new one we have an update. if ($status == 'deleted') { @@ -1244,7 +1244,7 @@ function _locale_rebuild_js($langcode = NULL) { } } else { - $locale_javascripts[$language->langcode] = ''; + $locale_javascripts[$language->id] = ''; $status = 'error'; } } @@ -1262,7 +1262,7 @@ function _locale_rebuild_js($langcode = NULL) { watchdog('locale', 'Updated JavaScript translation file for the language %language.', array('%language' => $language->name)); return TRUE; case 'rebuilt': - watchdog('locale', 'JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->langcode]), WATCHDOG_WARNING); + watchdog('locale', 'JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->id]), WATCHDOG_WARNING); // Proceed to the 'created' case as the JavaScript translation file has // been created again. case 'created': diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index 51a9e3a..3f1de22 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -109,7 +109,7 @@ function locale_translate_filters() { } // Pick the current interface language code for the filter. - $default_langcode = language(Language::TYPE_INTERFACE)->langcode; + $default_langcode = language(Language::TYPE_INTERFACE)->id; if (!isset($language_options[$default_langcode])) { $available_langcodes = array_keys($language_options); $default_langcode = array_shift($available_langcodes); diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc index 99a8559..be7bebf 100644 --- a/core/modules/locale/locale.translation.inc +++ b/core/modules/locale/locale.translation.inc @@ -136,7 +136,7 @@ function locale_translation_build_sources($projects = array(), $langcodes = arra foreach ($projects as $project) { foreach ($langcodes as $langcode) { $source = locale_translation_source_build($project, $langcode); - $sources[$source->name . ':' . $source->langcode] = $source; + $sources[$source->name . ':' . $source->id] = $source; } } return $sources; @@ -238,7 +238,7 @@ function locale_translation_source_build($project, $langcode, $filename = NULL) // Create a source object with data of the project object. $source = clone $project; $source->project = $project->name; - $source->langcode = $langcode; + $source->id = $langcode; $filename = $filename ? $filename : config('locale.settings')->get('translation.default_filename'); diff --git a/core/modules/menu/lib/Drupal/menu/MenuFormController.php b/core/modules/menu/lib/Drupal/menu/MenuFormController.php index 62a92ff..47087b9 100644 --- a/core/modules/menu/lib/Drupal/menu/MenuFormController.php +++ b/core/modules/menu/lib/Drupal/menu/MenuFormController.php @@ -90,7 +90,7 @@ public function form(array $form, array &$form_state) { '#type' => 'language_select', '#title' => t('Menu language'), '#languages' => Language::STATE_ALL, - '#default_value' => $menu->langcode, + '#default_value' => $menu->id, ); // Unlike the menu langcode, the default language configuration for menu // links only works with language module installed. diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php index 0a8c245..ed7079f 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php @@ -42,7 +42,7 @@ function setUp() { // Add some custom languages. foreach (array('aa', 'bb', 'cc') as $language_code) { $language = new Language(array( - 'langcode' => $language_code, + 'id' => $language_code, 'name' => $this->randomName(), )); language_save($language); @@ -70,7 +70,7 @@ function testMenuLanguage() { // Check that the language settings were saved. // The menu name should have been prefixed. $menu_name = 'menu-' . $menu_name; - $this->assertEqual(entity_load('menu', $menu_name)->langcode, $edit['langcode']); + $this->assertEqual(entity_load('menu', $menu_name)->id, $edit['langcode']); $language_settings = language_get_default_configuration('menu_link', $menu_name); $this->assertEqual($language_settings['langcode'], 'bb'); $this->assertEqual($language_settings['language_show'], TRUE); diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php index fa0d4c5..f6565de 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php @@ -190,13 +190,13 @@ public function form(array $form, array &$form_state) { // be configured individually. if ($this->moduleHandler->moduleExists('language')) { $language_configuration = language_get_default_configuration('menu_link', $menu_link->bundle()); - $default_langcode = ($menu_link->isNew() ? $language_configuration['langcode'] : $menu_link->langcode); + $default_langcode = ($menu_link->isNew() ? $language_configuration['langcode'] : $menu_link->id); $language_show = $language_configuration['language_show']; } // Without Language module menu links inherit the menu language and no // language selector is shown. else { - $default_langcode = ($menu_link->isNew() ? entity_load('menu', $menu_link->menu_name)->langcode : $menu_link->langcode); + $default_langcode = ($menu_link->isNew() ? entity_load('menu', $menu_link->menu_name)->id : $menu_link->id); $language_show = FALSE; } diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index e64db93..35af40c 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -108,7 +108,7 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $node->langcode, + '#default_value' => $node->id, '#languages' => Language::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); diff --git a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php index 0791287..629dd15 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php @@ -214,7 +214,7 @@ protected function init() { unset($this->uuid); unset($this->type); unset($this->title); - unset($this->uid); + unset($this->langcode); unset($this->status); unset($this->created); unset($this->changed); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php index d613cc4..4a6429b 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php @@ -58,11 +58,11 @@ public function setUp() { // Add Hungarian and Catalan. $language = new Language(array( - 'langcode' => 'hu', + 'id' => 'hu', )); language_save($language); $language = new Language(array( - 'langcode' => 'ca', + 'id' => 'ca', )); language_save($language); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php index be89d79..0fdd4a9 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php @@ -58,11 +58,11 @@ public function setUp() { // Add Hungarian and Catalan. $language = new Language(array( - 'langcode' => 'hu', + 'id' => 'hu', )); language_save($language); $language = new Language(array( - 'langcode' => 'ca', + 'id' => 'ca', )); language_save($language); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php index 7e7c70a..16348f0 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php @@ -40,11 +40,11 @@ function setUp() { // Add Hungarian and Catalan. $language = new Language(array( - 'langcode' => 'hu', + 'id' => 'hu', )); language_save($language); $language = new Language(array( - 'langcode' => 'ca', + 'id' => 'ca', )); language_save($language); } @@ -61,7 +61,7 @@ function testNodeAccess() { // Creating a public node with langcode Hungarian, will be saved as the // fallback in node access table. $node_public = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => FALSE)); - $this->assertTrue($node_public->langcode == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_public->id == 'hu', 'Node created as Hungarian.'); // Tests the default access is provided for the public Hungarian node. $this->assertNodeAccess($expected_node_access, $node_public, $web_user); @@ -78,7 +78,7 @@ function testNodeAccess() { // Creating a public node with no special langcode, like when no language // module enabled. $node_public_no_language = $this->drupalCreateNode(array('private' => FALSE)); - $this->assertTrue($node_public_no_language->langcode == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_public_no_language->id == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Tests that access is granted if requested with no language. $this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user); @@ -113,14 +113,14 @@ function testNodeAccessPrivate() { $web_user = $this->drupalCreateUser(array('access content')); $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu')); - $this->assertTrue($node->langcode == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node->id == 'hu', 'Node created as Hungarian.'); $expected_node_access = array('view' => TRUE, 'update' => FALSE, 'delete' => FALSE); $expected_node_access_no_access = array('view' => FALSE, 'update' => FALSE, 'delete' => FALSE); // Creating a private node with langcode Hungarian, will be saved as the // fallback in node access table. $node_public = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => TRUE)); - $this->assertTrue($node_public->langcode == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_public->id == 'hu', 'Node created as Hungarian.'); // Tests the default access is not provided for the private Hungarian node. $this->assertNodeAccess($expected_node_access_no_access, $node_public, $web_user); @@ -137,7 +137,7 @@ function testNodeAccessPrivate() { // Creating a private node with no special langcode, like when no language // module enabled. $node_private_no_language = $this->drupalCreateNode(array('private' => TRUE)); - $this->assertTrue($node_private_no_language->langcode == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_private_no_language->id == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Tests that access is not granted if requested with no language. $this->assertNodeAccess($expected_node_access_no_access, $node_private_no_language, $web_user); @@ -179,17 +179,17 @@ function testNodeAccessQueryTag() { // Creating a private node with langcode Hungarian, will be saved as // the fallback in node access table. $node_private = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => TRUE)); - $this->assertTrue($node_private->langcode == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_private->id == 'hu', 'Node created as Hungarian.'); // Creating a public node with langcode Hungarian, will be saved as // the fallback in node access table. $node_public = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => FALSE)); - $this->assertTrue($node_public->langcode == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_public->id == 'hu', 'Node created as Hungarian.'); // Creating a public node with no special langcode, like when no language // module enabled. $node_no_language = $this->drupalCreateNode(array('private' => FALSE)); - $this->assertTrue($node_no_language->langcode == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_no_language->id == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Query the nodes table as the web user with the node access tag and no // specific langcode. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php index e9447ec..cbf3a29 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php @@ -42,7 +42,7 @@ function setUp() { // Add a new language. $language = new Language(array( - 'langcode' => 'it', + 'id' => 'it', 'name' => 'Italian', )); language_save($language); @@ -84,7 +84,7 @@ function testMultilingualNodeForm() { // Check that the node exists in the database. $node = $this->drupalGetNodeByTitle($edit[$title_key])->getNGEntity(); $this->assertTrue($node, 'Node found in database.'); - $this->assertTrue($node->language()->langcode == $langcode && $node->body->value == $body_value, 'Field language correctly set.'); + $this->assertTrue($node->language()->id == $langcode && $node->body->value == $body_value, 'Field language correctly set.'); // Change node language. $langcode = 'it'; @@ -96,7 +96,7 @@ function testMultilingualNodeForm() { $this->drupalPost(NULL, $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit[$title_key], TRUE)->getNGEntity(); $this->assertTrue($node, 'Node found in database.'); - $this->assertTrue($node->language()->langcode == $langcode && $node->body->value == $body_value, 'Field language correctly changed.'); + $this->assertTrue($node->language()->id == $langcode && $node->body->value == $body_value, 'Field language correctly changed.'); // Enable content language URL detection. language_negotiation_set(Language::TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0)); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php index 67cf0b5..a5751eb 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php @@ -59,7 +59,7 @@ function setUp() { // Create revision with a random title and body and update variables. $node->title = $this->randomName(); - $node->body[$node->language()->langcode][0] = array( + $node->body[$node->language()->id][0] = array( 'value' => $this->randomName(32), 'format' => filter_default_format(), ); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php index 640175a..dd2df8d 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php @@ -59,7 +59,7 @@ function setUp() { // Create revision with a random title and body and update variables. $node->title = $this->randomName(); - $node->body[$node->language()->langcode][0] = array( + $node->body[$node->language()->id][0] = array( 'value' => $this->randomName(32), 'format' => filter_default_format(), ); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php index 90b7493..f726b07 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php @@ -54,34 +54,34 @@ function testNodeTokenReplacement() { $tests['[node:type]'] = 'article'; $tests['[node:type-name]'] = 'Article'; $tests['[node:title]'] = check_plain($node->title); - $tests['[node:body]'] = text_sanitize($instance['settings']['text_processing'], $node->langcode, $node->body[$node->langcode][0], 'value'); - $tests['[node:summary]'] = text_sanitize($instance['settings']['text_processing'], $node->langcode, $node->body[$node->langcode][0], 'summary'); - $tests['[node:langcode]'] = check_plain($node->langcode); + $tests['[node:body]'] = text_sanitize($instance['settings']['text_processing'], $node->id, $node->body[$node->id][0], 'value'); + $tests['[node:summary]'] = text_sanitize($instance['settings']['text_processing'], $node->id, $node->body[$node->id][0], 'summary'); + $tests['[node:langcode]'] = check_plain($node->id); $tests['[node:url]'] = url('node/' . $node->nid, $url_options); $tests['[node:edit-url]'] = url('node/' . $node->nid . '/edit', $url_options); $tests['[node:author]'] = check_plain(user_format_name($account)); $tests['[node:author:uid]'] = $node->uid; $tests['[node:author:name]'] = check_plain(user_format_name($account)); - $tests['[node:created:since]'] = format_interval(REQUEST_TIME - $node->created, 2, $language_interface->langcode); - $tests['[node:changed:since]'] = format_interval(REQUEST_TIME - $node->changed, 2, $language_interface->langcode); + $tests['[node:created:since]'] = format_interval(REQUEST_TIME - $node->created, 2, $language_interface->id); + $tests['[node:changed:since]'] = format_interval(REQUEST_TIME - $node->changed, 2, $language_interface->id); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('node' => $node), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array('node' => $node), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. $tests['[node:title]'] = $node->title; - $tests['[node:body]'] = $node->body[$node->langcode][0]['value']; - $tests['[node:summary]'] = $node->body[$node->langcode][0]['summary']; - $tests['[node:langcode]'] = $node->langcode; + $tests['[node:body]'] = $node->body[$node->id][0]['value']; + $tests['[node:summary]'] = $node->body[$node->id][0]['summary']; + $tests['[node:langcode]'] = $node->id; $tests['[node:author:name]'] = user_format_name($account); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('node' => $node), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('node' => $node), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input))); } @@ -96,7 +96,7 @@ function testNodeTokenReplacement() { // Generate and test sanitized token - use full body as expected value. $tests = array(); - $tests['[node:summary]'] = text_sanitize($instance['settings']['text_processing'], $node->langcode, $node->body[$node->langcode][0], 'value'); + $tests['[node:summary]'] = text_sanitize($instance['settings']['text_processing'], $node->id, $node->body[$node->id][0], 'value'); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated for node without a summary.'); @@ -107,7 +107,7 @@ function testNodeTokenReplacement() { } // Generate and test unsanitized tokens. - $tests['[node:summary]'] = $node->body[$node->langcode][0]['value']; + $tests['[node:summary]'] = $node->body[$node->id][0]['value']; foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('node' => $node), array('language' => $language_interface, 'sanitize' => FALSE)); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php index bea3245..e5966b9 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php @@ -91,14 +91,14 @@ protected function assertPublishedStatus() { foreach ($actions as $index => $status_actions) { // (Un)publish the node translations and check that the translation // statuses are (un)published accordingly. - foreach ($this->langcodes as $langcode) { + foreach ($this->ids as $langcode) { if (!empty($status_actions)) { $action = array_shift($status_actions); } $this->drupalPost($path, array(), $action, array('language' => $languages[$langcode])); } $entity = entity_load($this->entityType, $this->entityId, TRUE); - foreach ($this->langcodes as $langcode) { + foreach ($this->ids as $langcode) { // The node is created as unpulished thus we switch to the published // status first. $status = !$index; @@ -117,7 +117,7 @@ protected function assertAuthoringInfo() { $values = array(); // Post different authoring information for each translation. - foreach ($this->langcodes as $index => $langcode) { + foreach ($this->ids as $index => $langcode) { $user = $this->drupalCreateUser(); $values[$langcode] = array( 'uid' => $user->uid, @@ -132,7 +132,7 @@ protected function assertAuthoringInfo() { } $entity = entity_load($this->entityType, $this->entityId, TRUE); - foreach ($this->langcodes as $langcode) { + foreach ($this->ids as $langcode) { $this->assertEqual($entity->translation[$langcode]['uid'] == $values[$langcode]['uid'], 'Translation author correctly stored.'); $this->assertEqual($entity->translation[$langcode]['created'] == $values[$langcode]['created'], 'Translation date correctly stored.'); } diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index 821f41a..5722247 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -259,7 +259,7 @@ function node_admin_nodes() { '#empty' => t('No content available.'), ); foreach ($nodes as $node) { - $l_options = $node->langcode != Language::LANGCODE_NOT_SPECIFIED && isset($languages[$node->langcode]) ? array('language' => $languages[$node->langcode]) : array(); + $l_options = $node->id != Language::LANGCODE_NOT_SPECIFIED && isset($languages[$node->id]) ? array('language' => $languages[$node->id]) : array(); $mark = array( '#theme' => 'mark', '#mark_type' => node_mark($node->nid, $node->changed), @@ -286,7 +286,7 @@ function node_admin_nodes() { ); if ($multilingual) { $form['nodes'][$node->nid]['language_name'] = array( - '#markup' => language_name($node->langcode), + '#markup' => language_name($node->id), ); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index fbdf07d..80edd26 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -676,7 +676,7 @@ function node_type_update_nodes($old_type, $type) { * type object by $type->disabled being set to TRUE. */ function _node_types_build($rebuild = FALSE) { - $cid = 'node_types:' . language(Language::TYPE_INTERFACE)->langcode; + $cid = 'node_types:' . language(Language::TYPE_INTERFACE)->id; if (!$rebuild) { $_node_types = &drupal_static(__FUNCTION__); @@ -1289,16 +1289,16 @@ function node_search_execute($keys = NULL, $conditions = NULL) { foreach ($find as $item) { // Render the node. $node = node_load($item->sid); - $build = node_view($node, 'search_result', $item->langcode); + $build = node_view($node, 'search_result', $item->id); unset($build['#theme']); $node->rendered = drupal_render($build); // Fetch comments for snippet. - $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node, $item->langcode); + $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node, $item->id); - $extra = module_invoke_all('node_search_result', $node, $item->langcode); + $extra = module_invoke_all('node_search_result', $node, $item->id); - $language = language_load($item->langcode); + $language = language_load($item->id); $uri = $node->uri(); $username = array( '#theme' => 'username', @@ -1307,14 +1307,14 @@ function node_search_execute($keys = NULL, $conditions = NULL) { $results[] = array( 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))), 'type' => check_plain(node_get_type_label($node)), - 'title' => $node->label($item->langcode), + 'title' => $node->label($item->id), 'user' => drupal_render($username), 'date' => $node->changed, 'node' => $node, 'extra' => $extra, 'score' => $item->calculated_score, - 'snippet' => search_excerpt($keys, $node->rendered, $item->langcode), - 'langcode' => $node->langcode, + 'snippet' => search_excerpt($keys, $node->rendered, $item->id), + 'langcode' => $node->id, ); } return $results; @@ -1492,7 +1492,7 @@ function _node_revision_access(EntityInterface $node, $op = 'view', $account = N // If no language code was provided, default to the node revision's langcode. if (empty($langcode)) { - $langcode = $node->langcode; + $langcode = $node->id; } // Statically cache access by revision ID, language code, user account ID, @@ -2061,7 +2061,7 @@ function node_feed($nids = FALSE, $channel = array()) { 'title' => config('system.site')->get('name'), 'link' => $base_url, 'description' => $rss_config->get('channel.description'), - 'language' => $language_content->langcode + 'language' => $language_content->id ); $channel_extras = array_diff_key($channel, $channel_defaults); $channel = array_merge($channel_defaults, $channel); @@ -2182,21 +2182,21 @@ function _node_index_node(EntityInterface $node) { foreach ($languages as $language) { // Render the node. - $build = node_view($node, 'search_index', $language->langcode); + $build = node_view($node, 'search_index', $language->id); unset($build['#theme']); $node->rendered = drupal_render($build); - $text = '

' . check_plain($node->label($language->langcode)) . '

' . $node->rendered; + $text = '

' . check_plain($node->label($language->id)) . '

' . $node->rendered; // Fetch extra data normally not visible. - $extra = module_invoke_all('node_update_index', $node, $language->langcode); + $extra = module_invoke_all('node_update_index', $node, $language->id); foreach ($extra as $t) { $text .= $t; } // Update index. - search_index($node->nid, 'node', $text, $language->langcode); + search_index($node->nid, 'node', $text, $language->id); } } @@ -2469,14 +2469,14 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) { // If no language code was provided, default to the node's langcode. if (empty($langcode)) { - $langcode = $node->langcode; + $langcode = $node->id; // If the Language module is enabled, try to use the language from content // negotiation. if (module_exists('language')) { // Load languages the node exists in. $node_translations = $node->getTranslationLanguages(); // Load the language from content negotiation. - $content_negotiation_langcode = language(Language::TYPE_CONTENT)->langcode; + $content_negotiation_langcode = language(Language::TYPE_CONTENT)->id; // If there is a translation available, use it. if (isset($node_translations[$content_negotiation_langcode])) { $langcode = $content_negotiation_langcode; @@ -2892,7 +2892,7 @@ function _node_access_write_grants(EntityInterface $node, $grants, $realm = NULL $grant['nid'] = $node->nid; $grant['langcode'] = $grant_langcode; // The record with the original langcode is used as the fallback. - if ($grant['langcode'] == $node->langcode) { + if ($grant['langcode'] == $node->id) { $grant['fallback'] = 1; } else { @@ -3152,7 +3152,7 @@ function node_language_delete($language) { // On nodes with this language, unset the language. db_update('node') ->fields(array('langcode' => '')) - ->condition('langcode', $language->langcode) + ->condition('langcode', $language->id) ->execute(); } diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 155f595..af8e1e7 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -90,7 +90,7 @@ function node_add($node_type) { 'uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, - 'langcode' => $langcode ? $langcode : language_default()->langcode, + 'langcode' => $langcode ? $langcode : language_default()->id, ))->getBCEntity(); drupal_set_title(t('Create @name', array('@name' => $node_type->name)), PASS_THROUGH); return Drupal::entityManager()->getForm($node); diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index 241b83b..5d5e03f 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -171,7 +171,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'langcode': - $replacements[$original] = $sanitize ? check_plain($node->langcode) : $node->langcode; + $replacements[$original] = $sanitize ? check_plain($node->id) : $node->id; break; case 'url': diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php index 291b633..76acd68 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -99,7 +99,7 @@ function testAliasTranslation() { drupal_static_reset('language_list'); $this->rebuildContainer(); $languages = language_list(); - $url = $this->container->get('url_generator')->generateFromPath('node/' . $french_node->nid, array('language' => $languages[$french_node->langcode])); + $url = $this->container->get('url_generator')->generateFromPath('node/' . $french_node->nid, array('language' => $languages[$french_node->id])); $this->assertTrue(strpos($url, $edit['path[alias]']), 'URL contains the path alias.'); @@ -150,17 +150,17 @@ function testAliasTranslation() { // The alias manager has an internal path lookup cache. Check to see that // it has the appropriate contents at this point. $this->container->get('path.alias_manager')->cacheClear(); - $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode); + $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->id); $this->assertEqual($french_node_path, 'node/' . $french_node->nid, 'Normal path works.'); // Second call should return the same path. - $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode); + $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->id); $this->assertEqual($french_node_path, 'node/' . $french_node->nid, 'Normal path is the same.'); // Confirm that the alias works. - $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->langcode); + $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->id); $this->assertEqual($french_node_alias, $french_alias, 'Alias works.'); // Second call should return the same alias. - $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->langcode); + $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->id); $this->assertEqual($french_node_alias, $french_alias, 'Alias is the same.'); } } diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc index b03f8d6..fbe40c8 100644 --- a/core/modules/path/path.admin.inc +++ b/core/modules/path/path.admin.inc @@ -54,7 +54,7 @@ function path_admin_overview($keys = NULL) { 'attributes' => array('title' => $data->source), )); if ($multilanguage) { - $row['data']['language_name'] = language_name($data->langcode); + $row['data']['language_name'] = language_name($data->id); } $operations = array(); @@ -77,7 +77,7 @@ function path_admin_overview($keys = NULL) { // If the system path maps to a different URL alias, highlight this table // row to let the user know of old aliases. - if ($data->alias != Drupal::service('path.alias_manager')->getPathAlias($data->source, $data->langcode)) { + if ($data->alias != Drupal::service('path.alias_manager')->getPathAlias($data->source, $data->id)) { $row['class'] = array('warning'); } diff --git a/core/modules/path/path.module b/core/modules/path/path.module index efc59a8..fb1c841 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -101,8 +101,8 @@ function path_form_node_form_alter(&$form, $form_state) { $path = array(); if (!empty($node->nid)) { $conditions = array('source' => 'node/' . $node->nid); - if ($node->langcode != Language::LANGCODE_NOT_SPECIFIED) { - $conditions['langcode'] = $node->langcode; + if ($node->id != Language::LANGCODE_NOT_SPECIFIED) { + $conditions['langcode'] = $node->id; } $path = Drupal::service('path.crud')->load($conditions); if ($path === FALSE) { @@ -113,7 +113,7 @@ function path_form_node_form_alter(&$form, $form_state) { 'pid' => NULL, 'source' => isset($node->nid) ? 'node/' . $node->nid : NULL, 'alias' => '', - 'langcode' => isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => isset($node->id) ? $node->id : Language::LANGCODE_NOT_SPECIFIED, ); $form['path'] = array( @@ -191,7 +191,7 @@ function path_node_insert(EntityInterface $node) { if (!empty($alias)) { // Ensure fields for programmatic executions. $source = 'node/' . $node->nid; - $langcode = isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED; + $langcode = isset($node->id) ? $node->id : Language::LANGCODE_NOT_SPECIFIED; Drupal::service('path.crud')->save($source, $alias, $langcode); } } @@ -212,7 +212,7 @@ function path_node_update(EntityInterface $node) { if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $source = 'node/' . $node->nid; - $langcode = isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED; + $langcode = isset($node->id) ? $node->id : Language::LANGCODE_NOT_SPECIFIED; Drupal::service('path.crud')->save($source, $alias, $langcode, $path['pid']); } } diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php index f35b254..266c47d 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php @@ -36,12 +36,12 @@ function setUp() { // Add two new languages. $language = new Language(array( - 'langcode' => 'hu', + 'id' => 'hu', 'name' => 'Hungarian', )); language_save($language); $language = new Language(array( - 'langcode' => 'sv', + 'id' => 'sv', 'name' => 'Swedish', )); language_save($language); diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php index 028b803..60eb520 100644 --- a/core/modules/search/search.api.php +++ b/core/modules/search/search.api.php @@ -206,16 +206,16 @@ function hook_search_execute($keys = NULL, $conditions = NULL) { foreach ($find as $item) { // Render the node. $node = node_load($item->sid); - $build = node_view($node, 'search_result', $item->langcode); + $build = node_view($node, 'search_result', $item->id); unset($build['#theme']); $node->rendered = drupal_render($build); // Fetch comments for snippet. - $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node, $item->langcode); + $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node, $item->id); - $extra = module_invoke_all('node_search_result', $node, $item->langcode); + $extra = module_invoke_all('node_search_result', $node, $item->id); - $language = language_load($item->langcode); + $language = language_load($item->id); $uri = $node->uri(); $username = array( '#theme' => 'username', @@ -224,14 +224,14 @@ function hook_search_execute($keys = NULL, $conditions = NULL) { $results[] = array( 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))), 'type' => check_plain(node_get_type_label($node)), - 'title' => $node->label($item->langcode), + 'title' => $node->label($item->id), 'user' => drupal_render($username), 'date' => $node->changed, 'node' => $node, 'extra' => $extra, 'score' => $item->calculated_score, - 'snippet' => search_excerpt($keys, $node->rendered, $item->langcode), - 'langcode' => $node->langcode, + 'snippet' => search_excerpt($keys, $node->rendered, $item->id), + 'langcode' => $node->id, ); } return $results; diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index 646028a..1ca2b03 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -130,7 +130,7 @@ function template_preprocess_search_result(&$variables) { $result = $variables['result']; $variables['url'] = check_url($result['link']); $variables['title'] = check_plain($result['title']); - if (isset($result['language']) && $result['language'] != $language_interface->langcode && $result['language'] != Language::LANGCODE_NOT_SPECIFIED) { + if (isset($result['language']) && $result['language'] != $language_interface->id && $result['language'] != Language::LANGCODE_NOT_SPECIFIED) { $variables['title_attributes']['lang'] = $result['language']; $variables['content_attributes']['lang'] = $result['language']; } diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php index 7256c30..f13d5cb 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php @@ -56,7 +56,7 @@ function testStatisticsTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = \Drupal::token()->replace($input, array('node' => $node), array('langcode' => $language_interface->langcode)); + $output = \Drupal::token()->replace($input, array('node' => $node), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Statistics token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php index fb165a4..bfcb77f 100644 --- a/core/modules/system/language.api.php +++ b/core/modules/system/language.api.php @@ -27,8 +27,8 @@ function hook_language_switch_links_alter(array &$links, $type, $path) { $language_interface = language(\Drupal\Core\Language\Language::TYPE_INTERFACE); - if ($type == \Drupal\Core\Language\Language::TYPE_CONTENT && isset($links[$language_interface->langcode])) { - foreach ($links[$language_interface->langcode] as $link) { + if ($type == \Drupal\Core\Language\Language::TYPE_CONTENT && isset($links[$language_interface->id])) { + foreach ($links[$language_interface->id] as $link) { $link['attributes']['class'][] = 'active-language'; } } @@ -189,7 +189,7 @@ function hook_language_fallback_candidates_alter(array &$fallback_candidates) { * Here is a code snippet to transliterate some text: * @code * // Use the current default interface language. - * $langcode = language(\Drupal\Core\Language\Language::TYPE_INTERFACE)->langcode; + * $langcode = language(\Drupal\Core\Language\Language::TYPE_INTERFACE)->id; * // Instantiate the transliteration class. * $trans = drupal_container()->get('transliteration'); * // Use this to transliterate some text. diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php index cbce81f..b2efd41 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php @@ -102,7 +102,7 @@ public function buildForm(array $form, array &$form_state, $langcode = NULL, Req * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('locale.config.' . $this->language->langcode . '.system.date')->delete(); + $this->configFactory->get('locale.config.' . $this->language->id . '.system.date')->delete(); $form_state['redirect'] = 'admin/config/regional/date-time/locale'; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php index 118a059..af933e4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -127,8 +127,8 @@ function testFormatDate() { // Save the original user and language and then replace it with the test user and language. $real_user = $user; $user = user_load($test_user->uid, TRUE); - $real_language = $language_interface->langcode; - $language_interface->langcode = $user->preferred_langcode; + $real_language = $language_interface->id; + $language_interface->id = $user->preferred_langcode; // Simulate a Drupal bootstrap with the logged-in user. date_default_timezone_set(drupal_get_user_timezone()); @@ -150,7 +150,7 @@ function testFormatDate() { // Restore the original user and language, and enable session saving. $user = $real_user; - $language_interface->langcode = $real_language; + $language_interface->id = $real_language; // Restore default time zone. date_default_timezone_set(drupal_get_user_timezone()); drupal_save_session(TRUE); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php index 8b774bd..f6a7056 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php @@ -119,7 +119,7 @@ function testEntityTranslationAccess() { // Create two test languages. foreach (array('foo', 'bar') as $langcode) { $language = new Language(array( - 'langcode' => $langcode, + 'id' => $langcode, 'name' => $this->randomString(), )); language_save($language); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php index b070026..3ec26a4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php @@ -54,7 +54,7 @@ public function testDefaultValues() { */ protected function assertDefaultValues($entity_type) { $entity = entity_create($entity_type, array()); - $this->assertEqual($entity->langcode->value, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Default language', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->id->value, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Default language', array('%entity_type' => $entity_type))); $this->assertTrue($this->uuid->isValid($entity->uuid->value), format_string('%entity_type: Default UUID', array('%entity_type' => $entity_type))); $this->assertEqual($entity->name->getValue(), array(0 => array('value' => NULL)), 'Field has one empty value by default.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index 48b04ba..8b21e3a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -183,19 +183,19 @@ protected function assertReadWrite($entity_type) { $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type))); // Access the language field. - $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(language_load(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->id->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(language_load(Language::LANGCODE_NOT_SPECIFIED), $entity->id->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Change the language by code. - $entity->langcode->value = language_default()->langcode; - $this->assertEqual(language_default()->langcode, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(language_default(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $entity->id->value = language_default()->id; + $this->assertEqual(language_default()->id, $entity->id->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(language_default(), $entity->id->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Revert language by code then try setting it by language object. - $entity->langcode->value = Language::LANGCODE_NOT_SPECIFIED; - $entity->langcode->language = language_default(); - $this->assertEqual(language_default()->langcode, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(language_default(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $entity->id->value = Language::LANGCODE_NOT_SPECIFIED; + $entity->id->language = language_default(); + $this->assertEqual(language_default()->id, $entity->id->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(language_default(), $entity->id->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Access the text field and test updating. $this->assertEqual($entity->field_test_text->value, $this->entity_field_text, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); @@ -326,8 +326,8 @@ protected function assertSave($entity_type) { // Access the name field. $this->assertEqual(1, $entity->id->value, format_string('%entity_type: ID value can be read.', array('%entity_type' => $entity_type))); $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(language_load(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->id->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(language_load(Language::LANGCODE_NOT_SPECIFIED), $entity->id->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_user->uid, $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php index 94d762f..284526f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php @@ -109,17 +109,17 @@ function setUp() { )); // Make these languages available to the greetings field. $langcode = new Language(array( - 'langcode' => 'en', + 'id' => 'en', 'name' => $this->randomString(), )); language_save($langcode); $langcode = new Language(array( - 'langcode' => 'tr', + 'id' => 'tr', 'name' => $this->randomString(), )); language_save($langcode); $langcode = new Language(array( - 'langcode' => 'pl', + 'id' => 'pl', 'name' => $this->randomString(), )); language_save($langcode); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 80d00b8..6e502ca 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -38,13 +38,13 @@ function setUp() { \Drupal::state()->set('entity_test.translation', TRUE); // Create test languages. - $this->langcodes = array(); + $this->ids = array(); for ($i = 0; $i < 2; ++$i) { $language = new Language(array( - 'langcode' => 'l' . $i, + 'id' => 'l' . $i, 'name' => $this->randomString(), )); - $this->langcodes[$i] = $language->langcode; + $this->ids[$i] = $language->id; language_save($language); } } @@ -69,15 +69,15 @@ function testEntityFormLanguage() { $this->drupalPost(NULL, $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit["title"]); - $this->assertTrue($node->langcode == $form_langcode, 'Form language is the same as the entity language.'); + $this->assertTrue($node->id == $form_langcode, 'Form language is the same as the entity language.'); // Edit the node and test the form language. - $this->drupalGet($this->langcodes[0] . '/node/' . $node->nid . '/edit'); + $this->drupalGet($this->ids[0] . '/node/' . $node->nid . '/edit'); $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; - $this->assertTrue($node->langcode == $form_langcode, 'Form language is the same as the entity language.'); + $this->assertTrue($node->id == $form_langcode, 'Form language is the same as the entity language.'); // Explicitly set form langcode. - $langcode = $this->langcodes[0]; + $langcode = $this->ids[0]; $form_state['langcode'] = $langcode; \Drupal::entityManager()->getForm($node, 'default', $form_state); $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; @@ -91,7 +91,7 @@ function testEntityFormLanguage() { // Create a node with language. $edit = array(); - $langcode = $this->langcodes[0]; + $langcode = $this->ids[0]; $field_langcode = Language::LANGCODE_NOT_SPECIFIED; $edit["title"] = $this->randomName(8); $edit["body[$field_langcode][0][value]"] = $this->randomName(16); @@ -111,7 +111,7 @@ function testEntityFormLanguage() { $this->assertTrue($field['translatable'], 'Field body is translatable.'); // Create a body translation and check the form language. - $langcode2 = $this->langcodes[1]; + $langcode2 = $this->ids[1]; $node->body[$langcode2][0]['value'] = $this->randomName(16); $node->save(); $this->drupalGet($langcode2 . '/node/' . $node->nid . '/edit'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index 9d724a4..8a3e1fe 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -76,13 +76,13 @@ function setUp() { } // Create test languages. - $this->langcodes = array(); + $this->ids = array(); for ($i = 0; $i < 3; ++$i) { $language = new Language(array( - 'langcode' => 'l' . $i, + 'id' => 'l' . $i, 'name' => $this->randomString(), )); - $this->langcodes[$i] = $language->langcode; + $this->ids[$i] = $language->id; language_save($language); } } @@ -108,7 +108,7 @@ protected function assertEntityLanguageMethods($entity_type) { 'name' => 'test', 'user_id' => $GLOBALS['user']->uid, )); - $this->assertEqual($entity->language()->langcode, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->language()->id, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type))); $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); // Set the value in default language. @@ -119,19 +119,19 @@ protected function assertEntityLanguageMethods($entity_type) { // Set the value in a certain language. As the entity is not // language-specific it should use the default language and so ignore the // specified language. - $entity->getTranslation($this->langcodes[1])->set($this->field_name, array(0 => array('value' => 'default value2'))); + $entity->getTranslation($this->ids[1])->set($this->field_name, array(0 => array('value' => 'default value2'))); $this->assertEqual($entity->get($this->field_name)->value, 'default value2', format_string('%entity_type: Untranslated value updated.', array('%entity_type' => $entity_type))); $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); // Test getting a field value using a specific language for a not // language-specific entity. - $this->assertEqual($entity->getTranslation($this->langcodes[1])->get($this->field_name)->value, 'default value2', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->getTranslation($this->ids[1])->get($this->field_name)->value, 'default value2', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type))); // Now, make the entity language-specific by assigning a language and test // translating it. - $entity->langcode->value = $this->langcodes[0]; + $entity->id->value = $this->ids[0]; $entity->{$this->field_name} = array(); - $this->assertEqual($entity->language(), language_load($this->langcodes[0]), format_string('%entity_type: Entity language retrieved.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->language(), language_load($this->ids[0]), format_string('%entity_type: Entity language retrieved.', array('%entity_type' => $entity_type))); $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); // Set the value in default language. @@ -140,17 +140,17 @@ protected function assertEntityLanguageMethods($entity_type) { $this->assertEqual($entity->get($this->field_name)->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type))); // Set a translation. - $entity->getTranslation($this->langcodes[1])->set($this->field_name, array(0 => array('value' => 'translation 1'))); - $this->assertEqual($entity->getTranslation($this->langcodes[1])->{$this->field_name}->value, 'translation 1', format_string('%entity_type: Translated value set.', array('%entity_type' => $entity_type))); + $entity->getTranslation($this->ids[1])->set($this->field_name, array(0 => array('value' => 'translation 1'))); + $this->assertEqual($entity->getTranslation($this->ids[1])->{$this->field_name}->value, 'translation 1', format_string('%entity_type: Translated value set.', array('%entity_type' => $entity_type))); // Make sure the untranslated value stays. $this->assertEqual($entity->get($this->field_name)->value, 'default value', 'Untranslated value stays.'); - $translations[$this->langcodes[1]] = language_load($this->langcodes[1]); + $translations[$this->ids[1]] = language_load($this->ids[1]); $this->assertEqual($entity->getTranslationLanguages(FALSE), $translations, 'Translations retrieved.'); // Try to get a not available translation. - $this->assertNull($entity->getTranslation($this->langcodes[2])->get($this->field_name)->value, format_string('%entity_type: A translation that is not available is NULL.', array('%entity_type' => $entity_type))); + $this->assertNull($entity->getTranslation($this->ids[2])->get($this->field_name)->value, format_string('%entity_type: A translation that is not available is NULL.', array('%entity_type' => $entity_type))); // Try to get a value using an invalid language code. try { @@ -164,7 +164,7 @@ protected function assertEntityLanguageMethods($entity_type) { // Try to get an untranslatable value from a translation in strict mode. try { $field_name = 'field_test_text'; - $value = $entity->getTranslation($this->langcodes[1])->get($field_name); + $value = $entity->getTranslation($this->ids[1])->get($field_name); $this->fail(format_string('%entity_type: Getting an untranslatable value from a translation in strict mode throws an exception.', array('%entity_type' => $entity_type))); } catch (InvalidArgumentException $e) { @@ -174,7 +174,7 @@ protected function assertEntityLanguageMethods($entity_type) { // Try to get an untranslatable value from a translation in non-strict // mode. $entity->set($field_name, array(0 => array('value' => 'default value'))); - $value = $entity->getTranslation($this->langcodes[1], FALSE)->get($field_name)->value; + $value = $entity->getTranslation($this->ids[1], FALSE)->get($field_name)->value; $this->assertEqual($value, 'default value', format_string('%entity_type: Untranslated value retrieved from translation in non-strict mode.', array('%entity_type' => $entity_type))); // Try to set a value using an invalid language code. @@ -188,7 +188,7 @@ protected function assertEntityLanguageMethods($entity_type) { // Try to set an untranslatable value into a translation in strict mode. try { - $entity->getTranslation($this->langcodes[1])->set($field_name, NULL); + $entity->getTranslation($this->ids[1])->set($field_name, NULL); $this->fail(format_string('%entity_type: Setting an untranslatable value into a translation in strict mode throws an exception.', array('%entity_type' => $entity_type))); } catch (InvalidArgumentException $e) { @@ -196,7 +196,7 @@ protected function assertEntityLanguageMethods($entity_type) { } // Set the value in default language. - $entity->getTranslation($this->langcodes[1], FALSE)->set($field_name, array(0 => array('value' => 'default value2'))); + $entity->getTranslation($this->ids[1], FALSE)->set($field_name, array(0 => array('value' => 'default value2'))); // Get the value. $this->assertEqual($entity->get($field_name)->value, 'default value2', format_string('%entity_type: Untranslated value set into a translation in non-strict mode.', array('%entity_type' => $entity_type))); } @@ -220,14 +220,14 @@ public function testMultilingualProperties() { protected function assertMultilingualProperties($entity_type) { $name = $this->randomName(); $uid = mt_rand(0, 127); - $langcode = $this->langcodes[0]; + $langcode = $this->ids[0]; // Create a language neutral entity and check that properties are stored // as language neutral. $entity = entity_create($entity_type, array('name' => $name, 'user_id' => $uid)); $entity->save(); $entity = entity_load($entity_type, $entity->id()); - $this->assertEqual($entity->language()->langcode, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->language()->id, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type))); $this->assertEqual($name, $entity->getTranslation(Language::LANGCODE_DEFAULT)->get('name')->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); $this->assertEqual($uid, $entity->getTranslation(Language::LANGCODE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); // As fields, translatable properties should ignore the given langcode and @@ -242,7 +242,7 @@ protected function assertMultilingualProperties($entity_type) { $entity = entity_create($entity_type, array('name' => $name, 'user_id' => $uid, 'langcode' => $langcode)); $entity->save(); $entity = entity_load($entity_type, $entity->id()); - $this->assertEqual($entity->language()->langcode, $langcode, format_string('%entity_type: Entity created as language specific.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->language()->id, $langcode, format_string('%entity_type: Entity created as language specific.', array('%entity_type' => $entity_type))); $this->assertEqual($name, $entity->getTranslation($langcode)->get('name')->value, format_string('%entity_type: The entity name has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type))); $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type))); // Translatable properties on a translatable entity should use default @@ -255,7 +255,7 @@ protected function assertMultilingualProperties($entity_type) { // Create property translations. $properties = array(); $default_langcode = $langcode; - foreach ($this->langcodes as $langcode) { + foreach ($this->ids as $langcode) { if ($langcode != $default_langcode) { $properties[$langcode] = array( 'name' => array(0 => $this->randomName()), @@ -274,7 +274,7 @@ protected function assertMultilingualProperties($entity_type) { // Check that property translation were correctly stored. $entity = entity_load($entity_type, $entity->id()); - foreach ($this->langcodes as $langcode) { + foreach ($this->ids as $langcode) { $args = array( '%entity_type' => $entity_type, '%langcode' => $langcode, @@ -287,7 +287,7 @@ protected function assertMultilingualProperties($entity_type) { $translated_id = $entity->id(); // Create an additional entity with only the uid set. The uid for the // original language is the same of one used for a translation. - $langcode = $this->langcodes[1]; + $langcode = $this->ids[1]; entity_create($entity_type, array( 'user_id' => $properties[$langcode]['user_id'], 'name' => 'some name', diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php index f1a0fdb..62162eb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php @@ -110,7 +110,7 @@ protected function checkValidation($entity_type) { $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => '128'))); $test_entity = clone $entity; - $test_entity->langcode->value = $this->randomString(13); + $test_entity->id->value = $this->randomString(13); $violations = $test_entity->validate(); $this->assertEqual($violations->count(), 1, 'Validation failed.'); $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => '12'))); diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php index 09044e6..2705aed 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php @@ -36,13 +36,13 @@ public static function getInfo() { function testLanguageSelectElementOptions() { // Add some languages. $language = new Language(array( - 'langcode' => 'aaa', + 'id' => 'aaa', 'name' => $this->randomName(), )); language_save($language); $language = new Language(array( - 'langcode' => 'bbb', + 'id' => 'bbb', 'name' => $this->randomName(), )); language_save($language); diff --git a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php index 3dad764..d832f06 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php @@ -53,7 +53,7 @@ public function testPluggableFramework() { $language_interface = language(Language::TYPE_INTERFACE); // Use MailTestCase for sending a message. - $message = drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language_interface->langcode); + $message = drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language_interface->id); // Assert whether the message was sent through the send function. $this->assertEqual(self::$sent_message['to'], 'testing@example.com', 'Pluggable mail system is extendable.'); @@ -71,7 +71,7 @@ public function testCancelMessage() { self::$sent_message = NULL; // Send a test message that simpletest_mail_alter should cancel. - $message = drupal_mail('simpletest', 'cancel_test', 'cancel@example.com', $language_interface->langcode); + $message = drupal_mail('simpletest', 'cancel_test', 'cancel@example.com', $language_interface->id); // Assert that the message was not actually sent. $this->assertNull(self::$sent_message, 'Message was canceled.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorLanguageTest.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorLanguageTest.php index 23d01fa..1afeca5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorLanguageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorLanguageTest.php @@ -61,7 +61,7 @@ public function setUp() { // Create two languages: Spanish and German. $this->languages = array('de', 'es'); foreach ($this->languages as $langcode) { - $language = new Language(array('langcode' => $langcode)); + $language = new Language(array('id' => $langcode)); $languages[$langcode] = language_save($language); // Set up translations for each mock block label. $custom_strings = array(); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php index d32f297..a220835 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php @@ -45,18 +45,18 @@ function testTokenReplacement() { $target = check_plain($node->title); $target .= check_plain($account->name); - $target .= format_interval(REQUEST_TIME - $node->created, 2, $language_interface->langcode); + $target .= format_interval(REQUEST_TIME - $node->created, 2, $language_interface->id); $target .= check_plain($user->name); - $target .= format_date(REQUEST_TIME, 'short', '', NULL, $language_interface->langcode); + $target .= format_date(REQUEST_TIME, 'short', '', NULL, $language_interface->id); // Test that the clear parameter cleans out non-existent tokens. - $result = $token_service->replace($source, array('node' => $node), array('langcode' => $language_interface->langcode, 'clear' => TRUE)); + $result = $token_service->replace($source, array('node' => $node), array('langcode' => $language_interface->id, 'clear' => TRUE)); $result = $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens cleared out.'); // Test without using the clear parameter (non-existent token untouched). $target .= '[user:name]'; $target .= '[bogus:token]'; - $result = $token_service->replace($source, array('node' => $node), array('langcode' => $language_interface->langcode)); + $result = $token_service->replace($source, array('node' => $node), array('langcode' => $language_interface->id)); $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); // Check that the results of Token::generate are sanitized properly. This @@ -99,7 +99,7 @@ function testSystemTokenRecognition() { foreach ($tests as $test) { $input = $test['prefix'] . '[site:name]' . $test['suffix']; $expected = $test['prefix'] . 'Drupal' . $test['suffix']; - $output = $token_service->replace($input, array(), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array(), array('langcode' => $language_interface->id)); $this->assertTrue($output == $expected, format_string('Token recognized in string %string', array('%string' => $input))); } } @@ -134,7 +134,7 @@ function testSystemSiteTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array(), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array(), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized system site information token %token replaced.', array('%token' => $input))); } @@ -143,7 +143,7 @@ function testSystemSiteTokenReplacement() { $tests['[site:slogan]'] = config('system.site')->get('slogan'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array(), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array(), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized system site information token %token replaced.', array('%token' => $input))); } } @@ -160,18 +160,18 @@ function testSystemDateTokenReplacement() { // Generate and test tokens. $tests = array(); - $tests['[date:short]'] = format_date($date, 'short', '', NULL, $language_interface->langcode); - $tests['[date:medium]'] = format_date($date, 'medium', '', NULL, $language_interface->langcode); - $tests['[date:long]'] = format_date($date, 'long', '', NULL, $language_interface->langcode); - $tests['[date:custom:m/j/Y]'] = format_date($date, 'custom', 'm/j/Y', NULL, $language_interface->langcode); - $tests['[date:since]'] = format_interval((REQUEST_TIME - $date), 2, $language_interface->langcode); + $tests['[date:short]'] = format_date($date, 'short', '', NULL, $language_interface->id); + $tests['[date:medium]'] = format_date($date, 'medium', '', NULL, $language_interface->id); + $tests['[date:long]'] = format_date($date, 'long', '', NULL, $language_interface->id); + $tests['[date:custom:m/j/Y]'] = format_date($date, 'custom', 'm/j/Y', NULL, $language_interface->id); + $tests['[date:since]'] = format_interval((REQUEST_TIME - $date), 2, $language_interface->id); $tests['[date:raw]'] = filter_xss($date); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('date' => $date), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array('date' => $date), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Date token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php index c0e732e..a887243 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php @@ -58,10 +58,10 @@ public function testLanguageUpgrade() { )); // Ensure Catalan was properly upgraded to be the new default language. - $this->assertTrue(language_default()->langcode == 'ca', 'Catalan is the default language'); + $this->assertTrue(language_default()->id == 'ca', 'Catalan is the default language'); $languages = language_list(Language::STATE_ALL); foreach ($languages as $language) { - $this->assertTrue($language->default == ($language->langcode == 'ca'), format_string('@language default property properly set', array('@language' => $language->name))); + $this->assertTrue($language->default == ($language->id == 'ca'), format_string('@language default property properly set', array('@language' => $language->name))); } // Check that both comments display on the node. @@ -72,7 +72,7 @@ public function testLanguageUpgrade() { // Directly check the comment language property on the first comment. $comment = db_query('SELECT * FROM {comment} WHERE cid = :cid', array(':cid' => 1))->fetchObject(); - $this->assertTrue($comment->langcode == 'und', 'Comment 1 language code found.'); + $this->assertTrue($comment->id == 'und', 'Comment 1 language code found.'); // Ensure that the language switcher has been correctly upgraded. We need to // assert the expected HTML id because the block might appear even if the @@ -85,9 +85,9 @@ public function testLanguageUpgrade() { $spanish_nid = 51; $translation_source_nid = 52; $translation_nid = 53; - // Check directly for the $node->langcode property. - $this->assertEqual(node_load($language_none_nid)->langcode, Language::LANGCODE_NOT_SPECIFIED, "'language' property was renamed to 'langcode' for Language::LANGCODE_NOT_SPECIFIED node."); - $this->assertEqual(node_load($spanish_nid)->langcode, 'ca', "'language' property was renamed to 'langcode' for Catalan node."); + // Check directly for the $node->id property. + $this->assertEqual(node_load($language_none_nid)->id, Language::LANGCODE_NOT_SPECIFIED, "'language' property was renamed to 'langcode' for Language::LANGCODE_NOT_SPECIFIED node."); + $this->assertEqual(node_load($spanish_nid)->id, 'ca', "'language' property was renamed to 'langcode' for Catalan node."); // Check that the translation table works correctly. $this->drupalGet("node/$translation_source_nid/translate"); $this->assertResponse(200, 'The translated node has a proper translation table.'); @@ -104,20 +104,20 @@ public function testLanguageUpgrade() { // Check that the user language value was retained in both langcode and // preferred_langcode. $user = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => 1))->fetchObject(); - $this->assertEqual($user->langcode, 'ca'); + $this->assertEqual($user->id, 'ca'); $this->assertEqual($user->preferred_langcode, 'ca'); // A langcode property was added to vocabularies and terms. Check that // existing vocabularies and terms got assigned the site default language. $vocabulary = taxonomy_vocabulary_load('tags'); - $this->assertEqual($vocabulary->langcode, 'ca'); + $this->assertEqual($vocabulary->id, 'ca'); $term = db_query('SELECT * FROM {taxonomy_term_data} WHERE tid = :tid', array(':tid' => 1))->fetchObject(); - $this->assertEqual($term->langcode, 'ca'); + $this->assertEqual($term->id, 'ca'); // A langcode property was added to files. Check that existing files got // assigned Language::LANGCODE_NOT_SPECIFIED. $file = db_query('SELECT * FROM {file_managed} WHERE fid = :fid', array(':fid' => 1))->fetchObject(); - $this->assertEqual($file->langcode, Language::LANGCODE_NOT_SPECIFIED); + $this->assertEqual($file->id, Language::LANGCODE_NOT_SPECIFIED); // Check if language negotiation weights were renamed properly. This is a // reproduction of the previous weights from the dump. diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php index 376f1e9..8a80bda 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php @@ -46,7 +46,7 @@ public function testUserPictureUpgrade() { $this->assertIdentical($instance['settings']['default_image'][0], $file->id(), 'Default user picture has been migrated.'); $this->assertEqual($file->getFileUri(), 'public://user_pictures_dir/druplicon.png', 'File id matches the uri expected.'); $this->assertEqual($file->getFilename(), 'druplicon.png'); - $this->assertEqual($file->langcode->value, Language::LANGCODE_NOT_SPECIFIED); + $this->assertEqual($file->id->value, Language::LANGCODE_NOT_SPECIFIED); $this->assertEqual($file->getMimeType(), 'image/png'); $this->assertFalse(empty($file->uuid->value)); diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index e9e69c5..a0a428b 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -1856,7 +1856,7 @@ function hook_watchdog(array $log_entry) { '@message' => strip_tags($log_entry['message']), )); - drupal_mail('emaillog', 'entry', $to, $language_interface->langcode, $params); + drupal_mail('emaillog', 'entry', $to, $language_interface->id, $params); } /** diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php index 0ad1da0..a05d00b 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php @@ -47,7 +47,7 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $entity->language()->langcode, + '#default_value' => $entity->language()->id, '#languages' => Language::STATE_ALL, ); diff --git a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php index 139a01f..cc5b516 100644 --- a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php +++ b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php @@ -25,6 +25,6 @@ public function __construct() { // The CacheDecorator allows us to cache these plugin definitions for // quicker retrieval. In this case we are generating a cache key by // language. - $this->discovery = new CacheDecorator($this->discovery, 'mock_block:' . language(Language::TYPE_INTERFACE)->langcode, 'cache', 1542646800, array('plugin_test')); + $this->discovery = new CacheDecorator($this->discovery, 'mock_block:' . language(Language::TYPE_INTERFACE)->id, 'cache', 1542646800, array('plugin_test')); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php index 832a0cf..115ea10 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php @@ -47,7 +47,7 @@ public function form(array $form, array &$form_state) { '#type' => 'language_select', '#title' => t('Language'), '#languages' => Language::STATE_ALL, - '#default_value' => $term->langcode->value, + '#default_value' => $term->id->value, '#access' => !is_null($language_configuration['language_show']) && $language_configuration['language_show'], ); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php index b54b753..ba53d03 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php @@ -37,7 +37,7 @@ function setUp() { // Add some custom languages. foreach (array('aa', 'bb', 'cc') as $language_code) { $language = new Language(array( - 'langcode' => $language_code, + 'id' => $language_code, 'name' => $this->randomName(), )); language_save($language); @@ -63,7 +63,7 @@ function testTermLanguage() { $this->drupalPost(NULL, $edit, t('Save')); $terms = taxonomy_term_load_multiple_by_name($edit['name']); $term = reset($terms); - $this->assertEqual($term->language()->langcode, $edit['langcode']); + $this->assertEqual($term->language()->id, $edit['langcode']); // Check if on the edit page the language is correct. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php index 20f6988..7587847 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php @@ -102,7 +102,7 @@ function testTranslateLinkVocabularyAdminPage() { $this->admin_user = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), array('access administration pages', 'administer taxonomy'))); $this->drupalLogin($this->admin_user); - $translatable_tid = $this->createEntity(array(), $this->langcodes[0], $this->vocabulary->id()); + $translatable_tid = $this->createEntity(array(), $this->ids[0], $this->vocabulary->id()); // Create an untranslatable vocabulary. $untranslatable_vocabulary = entity_create('taxonomy_vocabulary', array( @@ -114,7 +114,7 @@ function testTranslateLinkVocabularyAdminPage() { )); $untranslatable_vocabulary->save(); - $untranslatable_tid = $this->createEntity(array(), $this->langcodes[0], $untranslatable_vocabulary->id()); + $untranslatable_tid = $this->createEntity(array(), $this->ids[0], $untranslatable_vocabulary->id()); // Verify translation links. $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id()); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php index eec5921..660d272 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php @@ -27,7 +27,7 @@ function setUp() { $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); $this->drupalLogin($this->admin_user); $this->vocabulary = $this->createVocabulary(); - $this->langcode = Language::LANGCODE_NOT_SPECIFIED; + $this->id = Language::LANGCODE_NOT_SPECIFIED; $this->field_name = 'taxonomy_' . $this->vocabulary->id(); entity_create('field_entity', array( 'field_name' => $this->field_name, @@ -80,7 +80,7 @@ function testTaxonomyTokenReplacement() { // Create node with term2. $edit = array(); $node = $this->drupalCreateNode(array('type' => 'article')); - $edit[$this->field_name . '[' . $this->langcode . '][]'] = $term2->id(); + $edit[$this->field_name . '[' . $this->id . '][]'] = $term2->id(); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); // Generate and test sanitized tokens for term1. @@ -94,7 +94,7 @@ function testTaxonomyTokenReplacement() { $tests['[term:vocabulary:name]'] = check_plain($this->vocabulary->name); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } @@ -114,7 +114,7 @@ function testTaxonomyTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } @@ -125,7 +125,7 @@ function testTaxonomyTokenReplacement() { $tests['[term:vocabulary:name]'] = $this->vocabulary->name; foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized taxonomy term token %token replaced.', array('%token' => $input))); } @@ -141,7 +141,7 @@ function testTaxonomyTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } @@ -150,7 +150,7 @@ function testTaxonomyTokenReplacement() { $tests['[vocabulary:description]'] = $this->vocabulary->description; foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php index 14c915c..cb4a2a8 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php @@ -33,13 +33,13 @@ function setUp() { // Add some custom languages. $language = new Language(array( - 'langcode' => 'aa', + 'id' => 'aa', 'name' => $this->randomName(), )); language_save($language); $language = new Language(array( - 'langcode' => 'bb', + 'id' => 'bb', 'name' => $this->randomName(), )); language_save($language); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php index db8c145..5559d46 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php @@ -55,7 +55,7 @@ public function form(array $form, array &$form_state) { '#type' => 'language_select', '#title' => t('Vocabulary language'), '#languages' => Language::STATE_ALL, - '#default_value' => $vocabulary->langcode, + '#default_value' => $vocabulary->id, ); if (module_exists('language')) { $form['default_terms_language'] = array( diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc index e8bd8e0..c9293ba 100644 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -15,7 +15,7 @@ function taxonomy_vocabulary_add() { $vocabulary = entity_create('taxonomy_vocabulary', array( // Default the new vocabulary to the site's default language. This is the // most likely default value until we have better flexible settings. - 'langcode' => language_default()->langcode, + 'langcode' => language_default()->id, )); return Drupal::entityManager()->getForm($vocabulary); } @@ -396,7 +396,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) { function taxonomy_term_add($vocabulary) { $term = entity_create('taxonomy_term', array('vid' => $vocabulary->id())); if (module_exists('language')) { - $term->langcode = language_get_default_langcode('taxonomy_term', $vocabulary->id()); + $term->id = language_get_default_langcode('taxonomy_term', $vocabulary->id()); } return Drupal::entityManager()->getForm($term); } diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install index f579755..4643926 100644 --- a/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -247,7 +247,7 @@ function taxonomy_update_8001() { // When updating from a site that did not already have taxonomy // internationalization, initialize all existing vocabularies and terms as // being in the site's default language. - $langcode_field['initial'] = language_default()->langcode; + $langcode_field['initial'] = language_default()->id; db_add_field($table, 'langcode', $langcode_field); } } @@ -319,7 +319,7 @@ function taxonomy_update_8005() { ->set('description', $vocabulary->description) ->set('hierarchy', $vocabulary->hierarchy) ->set('weight', $vocabulary->weight) - ->set('langcode', $vocabulary->langcode) + ->set('langcode', $vocabulary->id) ->save(); } } diff --git a/core/modules/text/lib/Drupal/text/Plugin/field/field_type/TextItemBase.php b/core/modules/text/lib/Drupal/text/Plugin/field/field_type/TextItemBase.php index 17f2ba3..80c93b3 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/field/field_type/TextItemBase.php +++ b/core/modules/text/lib/Drupal/text/Plugin/field/field_type/TextItemBase.php @@ -98,7 +98,7 @@ public function prepareCache() { // field in the filter cache separately. if (!$this->getInstance()->settings['text_processing'] || filter_format_allowcache($this->get('format')->getValue())) { $itemBC = $this->getValue(); - $langcode = $this->getParent()->getParent()->language()->langcode; + $langcode = $this->getParent()->getParent()->language()->id; $this->set('safe_value', text_sanitize($this->getInstance()->settings['text_processing'], $langcode, $itemBC, 'value')); if ($this->getType() == 'field_item:text_with_summary') { $this->set('safe_summary', text_sanitize($this->getInstance()->settings['text_processing'], $langcode, $itemBC, 'summary')); diff --git a/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php b/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php index 0a2b900..8b20c3f 100644 --- a/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php @@ -91,7 +91,7 @@ function setUp() { )); $this->display->save(); - $this->langcode = Language::LANGCODE_NOT_SPECIFIED; + $this->id = Language::LANGCODE_NOT_SPECIFIED; } /** diff --git a/core/modules/text/lib/Drupal/text/TextProcessed.php b/core/modules/text/lib/Drupal/text/TextProcessed.php index 2b5cb65..9a1910f 100644 --- a/core/modules/text/lib/Drupal/text/TextProcessed.php +++ b/core/modules/text/lib/Drupal/text/TextProcessed.php @@ -70,7 +70,7 @@ public function getValue($langcode = NULL) { $instance = field_info_instance($entity->entityType(), $field->getName(), $entity->bundle()); if (!empty($instance['settings']['text_processing']) && $this->format->getValue()) { - return check_markup($this->text->getValue(), $this->format->getValue(), $entity->language()->langcode); + return check_markup($this->text->getValue(), $this->format->getValue(), $entity->language()->id); } else { // If no format is available, still make sure to sanitize the text. diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index 52d3988..d281534 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -631,7 +631,7 @@ function toolbar_library_info() { */ function _toolbar_get_subtree_hash() { global $user; - $cid = $user->uid . ':' . language(Language::TYPE_INTERFACE)->langcode; + $cid = $user->uid . ':' . language(Language::TYPE_INTERFACE)->id; if ($cache = cache('toolbar')->get($cid)) { $hash = $cache->data; } diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php index db69e18..dcadd3f 100644 --- a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php +++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php @@ -88,7 +88,7 @@ public function testTourFunctionality() { // Enable Italian language and navigate to it/tour-test1 and verify italian // version of tip is found. - language_save(new Language(array('langcode' => 'it'))); + language_save(new Language(array('id' => 'it'))); $this->drupalGet('it/tour-test-1'); $elements = $this->xpath('//li[@data-id=:data_id and ./h2[contains(., :text)]]', array( @@ -103,7 +103,7 @@ public function testTourFunctionality() { )); $this->assertNotEqual(count($elements), 1, 'Did not find English variant of tip 1.'); - language_save(new Language(array('langcode' => 'en'))); + language_save(new Language(array('id' => 'en'))); // Programmatically create a tour for use through the remainder of the test. entity_create('tour', array( diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php index dff34a0..82dcf51 100644 --- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php +++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php @@ -444,8 +444,8 @@ function assertLanguageSwitchLinks($node, $translation, $find = TRUE, $types = N $result = TRUE; $languages = language_list(); - $page_language = $languages[$node->langcode]; - $translation_language = $languages[$translation->langcode]; + $page_language = $languages[$node->id]; + $translation_language = $languages[$translation->id]; $url = url("node/$translation->nid", array('language' => $translation_language)); $this->drupalGet("node/$node->nid", array('language' => $page_language)); diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index e8e872e..dd85213 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -86,7 +86,7 @@ function translation_menu() { * @see translation_menu() */ function _translation_tab_access($node) { - if ($node->langcode != Language::LANGCODE_NOT_SPECIFIED && translation_supported_type($node->type) && node_access('view', $node)) { + if ($node->id != Language::LANGCODE_NOT_SPECIFIED && translation_supported_type($node->type) && node_access('view', $node)) { return translation_user_can_translate_node($node); } return FALSE; @@ -270,7 +270,7 @@ function translation_node_view(EntityInterface $node, EntityDisplay $display, $v foreach ($translations as $langcode => $translation) { // Do not show links to the same node or to unpublished translations. - if ($translation->status && isset($languages[$langcode]) && $langcode != $node->langcode) { + if ($translation->status && isset($languages[$langcode]) && $langcode != $node->id) { $key = "translation_$langcode"; if (isset($custom_links->links[$langcode])) { @@ -323,7 +323,7 @@ function translation_node_prepare(EntityInterface $node) { $language_list = language_list(); $langcode = $target; - if (!isset($language_list[$langcode]) || ($source_node->langcode == $langcode)) { + if (!isset($language_list[$langcode]) || ($source_node->id == $langcode)) { // If not supported language, or same language as source node, break. return; } @@ -338,7 +338,7 @@ function translation_node_prepare(EntityInterface $node) { } // Populate fields based on source node. - $node->langcode = $langcode; + $node->id = $langcode; $node->translation_source = $source_node; $node->title = $source_node->title; } @@ -385,7 +385,7 @@ function translation_node_insert(EntityInterface $node) { function translation_node_update(EntityInterface $node) { // Only act if we are dealing with a content type supporting translations. if (translation_supported_type($node->type)) { - if (isset($node->translation) && $node->translation && !empty($node->langcode) && $node->tnid) { + if (isset($node->translation) && $node->translation && !empty($node->id) && $node->tnid) { // Update translation information. db_update('node') ->fields(array( @@ -417,7 +417,7 @@ function translation_node_validate(EntityInterface $node, $form, &$form_state) { if (translation_supported_type($node->type) && (!empty($node->tnid) || !empty($form_node->translation_source->nid))) { $tnid = !empty($node->tnid) ? $node->tnid : $form_node->translation_source->nid; $translations = translation_node_get_translations($tnid); - if (isset($translations[$node->langcode]) && $translations[$node->langcode]->nid != $node->nid) { + if (isset($translations[$node->id]) && $translations[$node->id]->nid != $node->nid) { form_set_error('langcode', t('There is already a translation in this language.')); } } @@ -499,7 +499,7 @@ function translation_node_get_translations($tnid) { $result = $query->execute(); foreach ($result as $node) { - $translations[$tnid][$node->langcode] = $node; + $translations[$tnid][$node->id] = $node; } } return $translations[$tnid]; @@ -552,10 +552,10 @@ function translation_language_switch_links_alter(array &$links, $type, $path) { // have translations it might be a language neutral node, in which case we // must leave the language switch links unaltered. This is true also for // nodes not having translation support enabled. - if (empty($node) || $node->langcode == Language::LANGCODE_NOT_SPECIFIED || !translation_supported_type($node->type)) { + if (empty($node) || $node->id == Language::LANGCODE_NOT_SPECIFIED || !translation_supported_type($node->type)) { return; } - $translations = array($node->langcode => $node); + $translations = array($node->id => $node); } else { $translations = translation_node_get_translations($node->tnid); diff --git a/core/modules/translation/translation.pages.inc b/core/modules/translation/translation.pages.inc index 7f85d3b..6575e47 100644 --- a/core/modules/translation/translation.pages.inc +++ b/core/modules/translation/translation.pages.inc @@ -30,7 +30,7 @@ function translation_node_overview(EntityInterface $node) { else { // We have no translation source nid, this could be a new set, emulate that. $tnid = $node->nid; - $translations = array($node->langcode => $node); + $translations = array($node->id => $node); } $type = config('translation.settings')->get('language_type'); diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc index 13a1383..2d03d49 100644 --- a/core/modules/update/update.fetch.inc +++ b/core/modules/update/update.fetch.inc @@ -352,7 +352,7 @@ function _update_cron_notify() { if (!empty($params)) { $notify_list = $update_config->get('notification.emails'); if (!empty($notify_list)) { - $default_langcode = language_default()->langcode; + $default_langcode = language_default()->id; foreach ($notify_list as $target) { if ($target_user = user_load_by_mail($target)) { $target_langcode = user_preferred_langcode($target_user); diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php index 13ad217..6505d29 100644 --- a/core/modules/user/lib/Drupal/user/AccountFormController.php +++ b/core/modules/user/lib/Drupal/user/AccountFormController.php @@ -176,9 +176,9 @@ public function form(array $form, array &$form_state) { '#format' => isset($account->signature_format) ? $account->signature_format : NULL, ); - $user_preferred_langcode = $register ? $language_interface->langcode : user_preferred_langcode($account); + $user_preferred_langcode = $register ? $language_interface->id : user_preferred_langcode($account); - $user_preferred_admin_langcode = $register ? $language_interface->langcode : user_preferred_langcode($account, 'admin'); + $user_preferred_admin_langcode = $register ? $language_interface->id : user_preferred_langcode($account, 'admin'); // Is default the interface language? include_once DRUPAL_ROOT . '/core/includes/language.inc'; diff --git a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php index 47fc23b..185a16f 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php @@ -129,7 +129,7 @@ public function validateForm(array &$form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $langcode = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->langcode; + $langcode = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id; $account = $form_state['values']['account']; // Mail one time login URL and instructions using current language. diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php index 65e3c24..edf59ae 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php @@ -72,7 +72,7 @@ function testLocalUserCreation() { $user = user_load_by_name($username); $this->assertEqual($user->preferred_langcode, $langcode, 'New user has correct preferred language set.'); - $this->assertEqual($user->langcode, $langcode, 'New user has correct profile language set.'); + $this->assertEqual($user->id, $langcode, 'New user has correct profile language set.'); // Register a new user and check if the language selector is hidden. $this->drupalLogout(); @@ -90,7 +90,7 @@ function testLocalUserCreation() { $user = user_load_by_name($username); $this->assertEqual($user->preferred_langcode, $langcode, 'New user has correct preferred language set.'); - $this->assertEqual($user->langcode, $langcode, 'New user has correct profile language set.'); + $this->assertEqual($user->id, $langcode, 'New user has correct profile language set.'); // Test if the admin can use the language selector and if the // correct language is was saved. diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php index 683bbda..68525b0 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php @@ -185,8 +185,8 @@ function testRegistrationDefaultValues() { $this->assertTrue(($new_user->created->value > REQUEST_TIME - 20 ), 'Correct creation time.'); $this->assertEqual($new_user->status->value, $config_user_settings->get('register') == USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.'); $this->assertEqual($new_user->timezone->value, $config_system_timezone->get('default'), 'Correct time zone field.'); - $this->assertEqual($new_user->langcode->value, language_default()->langcode, 'Correct language field.'); - $this->assertEqual($new_user->preferred_langcode->value, language_default()->langcode, 'Correct preferred language field.'); + $this->assertEqual($new_user->id->value, language_default()->id, 'Correct language field.'); + $this->assertEqual($new_user->preferred_langcode->value, language_default()->id, 'Correct preferred language field.'); $this->assertEqual($new_user->init->value, $mail, 'Correct init field.'); } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php index 43b9827..2dc6cce 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php @@ -32,7 +32,7 @@ function setUp() { */ function testRoleAdministration() { $this->drupalLogin($this->admin_user); - $default_langcode = language_default()->langcode; + $default_langcode = language_default()->id; // Test adding a role. (In doing so, we use a role name that happens to // correspond to an integer, to test that the role administration pages @@ -45,7 +45,7 @@ function testRoleAdministration() { $this->assertTrue(is_object($role), 'The role was successfully retrieved from the database.'); // Check that the role was created in site default language. - $this->assertEqual($role->langcode, $default_langcode); + $this->assertEqual($role->id, $default_langcode); // Try adding a duplicate role. $this->drupalPost('admin/people/roles/add', $edit, t('Save')); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php index 71d4a78..347f3d0 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php @@ -33,7 +33,7 @@ public static function getInfo() { public function setUp() { parent::setUp(); $language = new Language(array( - 'langcode' => 'de', + 'id' => 'de', )); language_save($language); } @@ -66,17 +66,17 @@ function testUserTokenReplacement() { $tests['[user:mail]'] = check_plain($account->mail); $tests['[user:url]'] = url("user/$account->uid", $url_options); $tests['[user:edit-url]'] = url("user/$account->uid/edit", $url_options); - $tests['[user:last-login]'] = format_date($account->login, 'medium', '', NULL, $language_interface->langcode); - $tests['[user:last-login:short]'] = format_date($account->login, 'short', '', NULL, $language_interface->langcode); - $tests['[user:created]'] = format_date($account->created, 'medium', '', NULL, $language_interface->langcode); - $tests['[user:created:short]'] = format_date($account->created, 'short', '', NULL, $language_interface->langcode); + $tests['[user:last-login]'] = format_date($account->login, 'medium', '', NULL, $language_interface->id); + $tests['[user:last-login:short]'] = format_date($account->login, 'short', '', NULL, $language_interface->id); + $tests['[user:created]'] = format_date($account->created, 'medium', '', NULL, $language_interface->id); + $tests['[user:created:short]'] = format_date($account->created, 'short', '', NULL, $language_interface->id); $tests['[current-user:name]'] = check_plain(user_format_name($global_account)); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->langcode)); + $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized user token %token replaced.', array('%token' => $input))); } @@ -86,7 +86,7 @@ function testUserTokenReplacement() { $tests['[current-user:name]'] = user_format_name($global_account); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized user token %token replaced.', array('%token' => $input))); } @@ -98,7 +98,7 @@ function testUserTokenReplacement() { // Generate tokens with interface language. $link = url('user', array('absolute' => TRUE)); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->langcode, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); + $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->id, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); $this->assertTrue(strpos($output, $link) === 0, 'Generated URL is in interface language.'); } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php b/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php index 0b7883f..b566e51 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php @@ -65,7 +65,7 @@ function testTranslateLinkUserAdminPage() { $this->admin_user = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), array('access administration pages', 'administer users'))); $this->drupalLogin($this->admin_user); - $uid = $this->createEntity(array('name' => $this->randomName()), $this->langcodes[0]); + $uid = $this->createEntity(array('name' => $this->randomName()), $this->ids[0]); // Verify translation links. $this->drupalGet('admin/people'); diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 41278fc..d1fe8ca 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -2198,10 +2198,10 @@ function user_preferred_langcode($account, $type = NULL, $default = NULL) { $preferred_langcode = $account->preferred_langcode; } if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) { - return $language_list[$preferred_langcode]->langcode; + return $language_list[$preferred_langcode]->id; } else { - return $default ? $default : language_default()->langcode; + return $default ? $default : language_default()->id; } } @@ -2257,7 +2257,7 @@ function _user_mail_notify($op, $account, $langcode = NULL) { if ($op == 'register_pending_approval') { // If a user registered requiring admin approval, notify the admin, too. // We use the site default language for this. - drupal_mail('user', 'register_pending_approval_admin', $site_mail, language_default()->langcode, $params); + drupal_mail('user', 'register_pending_approval_admin', $site_mail, language_default()->id, $params); } } return empty($mail) ? NULL : $mail['result']; diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php index 2b7fa9c..62ed735 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php @@ -287,7 +287,7 @@ public function generateResultsKey() { 'build_info' => $build_info, 'roles' => $user->roles, 'super-user' => $user->uid == 1, // special caching for super user. - 'langcode' => language(Language::TYPE_INTERFACE)->langcode, + 'langcode' => language(Language::TYPE_INTERFACE)->id, 'base_url' => $GLOBALS['base_url'], ); $request = \Drupal::request(); @@ -317,7 +317,7 @@ public function generateOutputKey() { 'roles' => $user->roles, 'super-user' => $user->uid == 1, // special caching for super user. 'theme' => $GLOBALS['theme'], - 'langcode' => language(Language::TYPE_INTERFACE)->langcode, + 'langcode' => language(Language::TYPE_INTERFACE)->id, 'base_url' => $GLOBALS['base_url'], ); diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php index 50a8215..cd56c28 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -624,7 +624,7 @@ protected function instantiateView($form, &$form_state) { 'label' => $form_state['values']['label'], 'description' => $form_state['values']['description'], 'base_table' => $this->base_table, - 'langcode' => language_default()->langcode, + 'langcode' => language_default()->id, ); $view = entity_create('view', $values); diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/WizardPluginBaseUnitTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/WizardPluginBaseUnitTest.php index 4c5f95c..8d2fad6 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/WizardPluginBaseUnitTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/WizardPluginBaseUnitTest.php @@ -66,7 +66,7 @@ public function testCreateView() { // Add a new language and mark it as default. $language = new Language(array( - 'langcode' => 'it', + 'id' => 'it', 'name' => 'Italian', 'default' => TRUE, )); diff --git a/core/modules/views/lib/Drupal/views/ViewsData.php b/core/modules/views/lib/Drupal/views/ViewsData.php index 2a1c2b2..118a557 100644 --- a/core/modules/views/lib/Drupal/views/ViewsData.php +++ b/core/modules/views/lib/Drupal/views/ViewsData.php @@ -96,7 +96,7 @@ public function __construct(CacheBackendInterface $cache_backend, ConfigFactory $this->moduleHandler = $module_handler; $this->languageManager = $language_manager; - $this->langcode = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->langcode; + $this->id = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id; $this->skipCache = $config->get('views.settings')->get('skip_cache'); } @@ -182,7 +182,7 @@ protected function cacheGet($cid) { * The prepared cache ID. */ protected function prepareCid($cid) { - return $cid . ':' . $this->langcode; + return $cid . ':' . $this->id; } /** diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index 6b4245b..24e16e5 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -318,8 +318,8 @@ function hook_views_query_substitutions(ViewExecutable $view) { return array( '***CURRENT_VERSION***' => VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***CURRENT_LANGUAGE***' => language(\Drupal\Core\Language\Language::TYPE_CONTENT)->langcode, - '***DEFAULT_LANGUAGE***' => language_default()->langcode, + '***CURRENT_LANGUAGE***' => language(\Drupal\Core\Language\Language::TYPE_CONTENT)->id, + '***DEFAULT_LANGUAGE***' => language_default()->id, ); } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 0e5922b..879fb03 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -640,7 +640,7 @@ function views_language_list($field = 'name', $flags = Language::STATE_ALL) { $languages = language_list($flags); $list = array(); foreach ($languages as $language) { - $list[$language->langcode] = ($field == 'name') ? t($language->name) : $language->$field; + $list[$language->id] = ($field == 'name') ? t($language->name) : $language->$field; } return $list; } @@ -1633,7 +1633,7 @@ function views_cache_set($cid, $data, $use_language = FALSE) { return; } if ($use_language) { - $cid .= ':' . language(Language::TYPE_INTERFACE)->langcode; + $cid .= ':' . language(Language::TYPE_INTERFACE)->id; } cache('views_info')->set($cid, $data); @@ -1657,7 +1657,7 @@ function views_cache_get($cid, $use_language = FALSE) { return FALSE; } if ($use_language) { - $cid .= ':' . language(Language::TYPE_INTERFACE)->langcode; + $cid .= ':' . language(Language::TYPE_INTERFACE)->id; } return cache('views_info')->get($cid); diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 627e8ed..40f1be8 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -1024,7 +1024,7 @@ function template_preprocess_views_view_rss(&$vars) { $vars['link'] = check_url(url($path, $url_options)); } - $vars['langcode'] = check_plain(language(Language::TYPE_INTERFACE)->langcode); + $vars['langcode'] = check_plain(language(Language::TYPE_INTERFACE)->id); $vars['namespaces'] = new Attribute($style->namespaces); $vars['items'] = $items; $vars['channel_elements'] = format_xml_elements($style->channel_elements); diff --git a/core/modules/views/views.tokens.inc b/core/modules/views/views.tokens.inc index fc119b8..ae307fd 100644 --- a/core/modules/views/views.tokens.inc +++ b/core/modules/views/views.tokens.inc @@ -74,7 +74,7 @@ function views_tokens($type, $tokens, array $data = array(), array $options = ar $url_options['language'] = $options['language']; } $sanitize = !empty($options['sanitize']); - $langcode = isset($options['language']) ? $options['language']->langcode : NULL; + $langcode = isset($options['language']) ? $options['language']->id : NULL; $replacements = array(); diff --git a/core/modules/views/views.views_execution.inc b/core/modules/views/views.views_execution.inc index 5b0966a..ddde9d9 100644 --- a/core/modules/views/views.views_execution.inc +++ b/core/modules/views/views.views_execution.inc @@ -17,7 +17,7 @@ function views_views_query_substitutions(ViewExecutable $view) { return array( '***CURRENT_VERSION***' => VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***CURRENT_LANGUAGE***' => language(Language::TYPE_CONTENT)->langcode, - '***DEFAULT_LANGUAGE***' => language_default()->langcode, + '***CURRENT_LANGUAGE***' => language(Language::TYPE_CONTENT)->id, + '***DEFAULT_LANGUAGE***' => language_default()->id, ); } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/StorageTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/StorageTest.php index 0f32d96..24582db 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/StorageTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/StorageTest.php @@ -44,7 +44,7 @@ public static function getInfo() { public function testDetails() { $view_name = 'test_view'; - $language = new Language(array('name' => 'French', 'langcode' => 'fr')); + $language = new Language(array('name' => 'French', 'id' => 'fr')); language_save($language); $edit = array( diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php index fdbcee6..f49184f 100644 --- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php +++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php @@ -39,7 +39,7 @@ public function setUp() { $languages = array(); foreach (array('en' => 'English', 'fr' => 'French') as $langcode => $language_name) { $language = new \stdClass(); - $language->langcode = $langcode; + $language->id = $langcode; $language->name = $language_name; $languages[$langcode] = $language; }