diff --git a/core/includes/common.inc b/core/includes/common.inc index 1f2b74bea037a99415979f9ac3907fd3c20fb09a..7415803b54090b17abd385986516e26aa54bb6b8 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -768,7 +768,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)->id; + $langcode = $langcode ? $langcode : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT)->id; $output = "\n"; $output .= ' ' . String::checkPlain($title) . "\n"; diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 0ade970ba5f565b65f82e741a379f1eb61a28c1f..39701ef14637c45e520af72d43fed87b9d90e3c1 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -93,7 +93,7 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N function entity_get_form_modes($entity_type = NULL) { $form_modes = &drupal_static(__FUNCTION__); if (!$form_modes) { - $langcode = language(Language::TYPE_INTERFACE)->id; + $langcode = \Drupal::languageManager()->getCurrentLanguage()->id; if ($cache = \Drupal::cache()->get("entity_form_mode_info:$langcode")) { $form_modes = $cache->data; } @@ -131,7 +131,7 @@ function entity_get_form_modes($entity_type = NULL) { function entity_get_view_modes($entity_type = NULL) { $view_modes = &drupal_static(__FUNCTION__); if (!$view_modes) { - $langcode = language(Language::TYPE_INTERFACE)->id; + $langcode = \Drupal::languageManager()->getCurrentLanguage()->id; if ($cache = \Drupal::cache()->get("entity_view_mode_info:$langcode")) { $view_modes = $cache->data; } diff --git a/core/includes/form.inc b/core/includes/form.inc index 454a01670bfb3f797b79c23aa32da97d7dc4a2cd..15c6634d8fbd975f6bac93d284331d557c78eed8 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -1898,7 +1898,7 @@ function form_validate_table($element, &$form_state) { */ function form_process_machine_name($element, &$form_state) { // We need to pass the langcode to the client. - $language = language(Language::TYPE_INTERFACE); + $language = \Drupal::languageManager()->getCurrentLanguage(); // Apply default form element properties. $element += array( diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 495fb4722b884c5dd762e9cb046ec2381ca03b19..053239e58411cf4ce1c23720a38f4f7ee644e876 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1009,7 +1009,7 @@ function menu_tree_output($tree) { */ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) { $tree = &drupal_static(__FUNCTION__, array()); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Use $mlid as a flag for whether the data being loaded is for the whole tree. $mlid = isset($link['mlid']) ? $link['mlid'] : 0; @@ -1120,7 +1120,7 @@ function menu_tree_get_path($menu_name) { function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE) { $tree = &drupal_static(__FUNCTION__, array()); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Check if the active trail has been overridden for this menu tree. $active_path = menu_tree_get_path($menu_name); @@ -1278,7 +1278,7 @@ function menu_build_tree($menu_name, array $parameters = array()) { function _menu_build_tree($menu_name, array $parameters = array()) { // Static cache of already built menu trees. $trees = &drupal_static(__FUNCTION__, array()); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Build the cache id; sort parents to prevent duplicate storage and remove // default parameter values. diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 2e7d41e4e6496b6ab3826ee64f36f6ef8e69d479..dad6f65bd625812dbdb1521b38253ed919941575 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2191,7 +2191,7 @@ function template_preprocess_html(&$variables) { * @see drupal_render_page() */ function template_preprocess_page(&$variables) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $site_config = \Drupal::config('system.site'); // Move some variables to the top level for themer convenience and template cleanliness. @@ -2365,7 +2365,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') { * @see system_page_build() */ function template_preprocess_maintenance_page(&$variables) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Initializes attributes which are specific to the html element. $variables['html_attributes'] = new Attribute; diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index 1ea2bc13ad9b0dae368d3aa7ef7a35947e436cdc..db285d9b23931618f68089d42fb0bb3f4006315f 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -455,7 +455,7 @@ public static function urlGenerator() { * displayed outside the site, such as in an RSS feed. * - 'language': An optional language object used to look up the alias * for the URL. If $options['language'] is omitted, the language will be - * obtained from language(Language::TYPE_URL). + * obtained from \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_URL). * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php index 08bdded821da3f7ab52c092b2d31c9bccf8edd31..2d4be4614dafbdfec2e4b81f70b78b5d8942c02b 100644 --- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php @@ -53,7 +53,7 @@ class DrupalDateTime extends DateTimePlus { public function __construct($time = 'now', $timezone = NULL, $settings = array()) { // We can set the langcode and country using Drupal values. if (!isset($settings['langcode'])) { - $settings['langcode'] = language(Language::TYPE_INTERFACE)->id; + $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->id; } if (!isset($settings['country'])) { diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php index 5c42a8189d22ef68316acbcc52be6889738c827d..9903fe336c98340ad384ac86fd7e2ed1378af2de 100644 --- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php +++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php @@ -13,7 +13,7 @@ /** * Defines an interface for generating a url from a route or system path. * - * Provides additional methods and options not present in the base interface. + * Provides additional methods and options not present in the base interface. */ interface UrlGeneratorInterface extends VersatileGeneratorInterface { @@ -55,7 +55,7 @@ interface UrlGeneratorInterface extends VersatileGeneratorInterface { * - 'language': An optional language object. If the path being linked to is * internal to the site, $options['language'] is used to look up the alias * for the URL. If $options['language'] is omitted, the language will be - * obtained from language(Language::TYPE_URL). + * obtained from \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_URL). * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS can @@ -121,8 +121,8 @@ public function getPathFromRoute($name, $parameters = array()); * absolute link (beginning with http:). Useful for links that will be * displayed outside the site, such as in an RSS feed. * - 'language': An optional language object used to look up the alias - * for the URL. If $options['language'] is omitted, the language will be - * obtained from language(Language::TYPE_URL). + * for the URL. If $options['language'] is omitted, it defaults to the + * current language for the language type Language::TYPE_URL. * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 23dbeaf03eadfcadff7336881f763936abc15c1a..33f91fc94bafee48ca41603fcb87ad6d4fce0167 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -82,8 +82,8 @@ class Url extends DependencySerialization { * absolute link (beginning with http:). Useful for links that will be * displayed outside the site, such as in an RSS feed. * - 'language': An optional language object used to look up the alias - * for the URL. If $options['language'] is omitted, the language will be - * obtained from language(Language::TYPE_URL). + * for the URL. If $options['language'] is omitted, it defaults to the + * current language for the language type Language::TYPE_URL. * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php index df14d942db00404e8ebe279de2c68829250d4c65..5b4d99dc4b290b38af271889c8f9ca99cf813d1c 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)->id; + return $this->locale ? $this->locale : \Drupal::languageManager()->getCurrentLanguage()->id; } /** diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php index 9469ffcb4a05c34f032a91999dcd40ee28853552..4f5182b0d471df861bdd032bb4b369805ad5fc7b 100644 --- a/core/modules/block/lib/Drupal/block/BlockAccessController.php +++ b/core/modules/block/lib/Drupal/block/BlockAccessController.php @@ -117,7 +117,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'])->id])) { + if (empty($visibility['language']['langcodes'][\Drupal::languageManager()->getCurrentLanguage($visibility['language']['language_type'])->id])) { return FALSE; } } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index b7a8cc776d2f1f64eb9dc813ef51915ac84c401f..b20123412c58a2fc4345b5bd1733123125e2fd93 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -713,7 +713,7 @@ function template_preprocess_book_navigation(&$variables) { */ function template_preprocess_book_export_html(&$variables) { global $base_url; - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $variables['title'] = String::checkPlain($variables['title']); $variables['base_url'] = $base_url; diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php index 8f3162c1f6d46cea5900cbebe5afb681bc882336..8edd4d70da4141583a00f5efb952d2574db3a919 100644 --- a/core/modules/book/lib/Drupal/book/BookManager.php +++ b/core/modules/book/lib/Drupal/book/BookManager.php @@ -552,7 +552,7 @@ public function deleteBook($nid) { */ public function bookTreeAllData($menu_name, $link = NULL, $max_depth = NULL) { $tree = &drupal_static('menu_tree_all_data', array()); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Use $mlid as a flag for whether the data being loaded is for the whole tree. $mlid = isset($link['mlid']) ? $link['mlid'] : 0; @@ -721,7 +721,7 @@ protected function menu_build_tree($menu_name, array $parameters = array()) { protected function _menu_build_tree($menu_name, array $parameters = array()) { // Static cache of already built menu trees. $trees = &drupal_static('menu_build_tree', array()); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Build the cache id; sort parents to prevent duplicate storage and remove // default parameter values. diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc index d8ef45f8f538a6317217fbea940314b581396a80..7d763c75ed857b2ac0fd27f2588ba5a5985302de 100644 --- a/core/modules/ckeditor/ckeditor.admin.inc +++ b/core/modules/ckeditor/ckeditor.admin.inc @@ -20,7 +20,7 @@ */ function template_preprocess_ckeditor_settings_toolbar(&$variables) { // Simplify the language direction information for toolbar buttons. - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $language_direction = $language_interface->direction ? 'rtl' : 'ltr'; // Create lists of active and disabled buttons. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php index 081775fd6217f8cafabecef50faf4dde13bb4051..bd300fc83877ef04f01964251273f69b8760a160 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php @@ -26,7 +26,7 @@ public static function getInfo() { */ function testCommentTokenReplacement() { $token_service = \Drupal::token(); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $url_options = array( 'absolute' => TRUE, 'language' => $language_interface, diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php index f8f57cf506def5d2b204fbc82d614a7b267c5cd7..067865444634c3b36958104c65f6289a2dda688d 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php @@ -141,7 +141,7 @@ public function preview(array $form, array &$form_state) { public function save(array $form, array &$form_state) { global $user; - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $message = $this->entity; $sender = clone user_load($user->id()); diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index d425866e86d44bf8224fda2a9a3bd43ccaffe568..8c65f1e9f37c6bdffe34f86765ff91dbb8814a23 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -372,7 +372,7 @@ function content_translation_view_access(EntityInterface $entity, $langcode, Acc */ function content_translation_add_access(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { $source = !empty($source) ? $source : $entity->language(); - $target = !empty($target) ? $target : language(Language::TYPE_CONTENT); + $target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); return $source->id != $target->id && isset($languages[$source->id]) && isset($languages[$target->id]) && !isset($translations[$target->id]) && content_translation_access($entity, 'create'); @@ -388,7 +388,7 @@ function content_translation_add_access(EntityInterface $entity, Language $sourc * content language. */ function content_translation_edit_access(EntityInterface $entity, Language $language = NULL) { - $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); + $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) && content_translation_access($entity, 'update'); @@ -404,7 +404,7 @@ function content_translation_edit_access(EntityInterface $entity, Language $lang * content language. */ function content_translation_delete_access(EntityInterface $entity, Language $language = NULL) { - $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); + $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) && content_translation_access($entity, 'delete'); diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index 0b6a4dc62479de9880f960cebe061a0f696b89ba..bed50a0472025c3d3653e3a7a9a4bf92ba8ad40b 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -184,7 +184,7 @@ function _content_translation_get_switch_links($path) { */ function content_translation_add_page(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { $source = !empty($source) ? $source : $entity->language(); - $target = !empty($target) ? $target : language(Language::TYPE_CONTENT); + $target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); // @todo Exploit the upcoming hook_entity_prepare() when available. content_translation_prepare_translation($entity, $source, $target); $form_state['langcode'] = $target->id; @@ -210,7 +210,7 @@ function content_translation_add_page(EntityInterface $entity, Language $source * Use \Drupal\content_translation\Controller\ContentTranslationController::edit(). */ function content_translation_edit_page(EntityInterface $entity, Language $language = NULL) { - $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); + $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $form_state['langcode'] = $language->id; $form_state['content_translation']['translation_form'] = TRUE; return \Drupal::service('entity.form_builder')->getForm($entity, 'default', $form_state); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php index be3fe8553f85654d3ed892cfbf0faed7dad33261..f1c3ea5ea054bc8173bcce5d618d719f168c0648 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php @@ -56,7 +56,7 @@ public function access(Route $route, Request $request, AccountInterface $account $source = language_load($request->attributes->get('source')); $target = language_load($request->attributes->get('target')); $source = !empty($source) ? $source : $entity->language(); - $target = !empty($target) ? $target : language(Language::TYPE_CONTENT); + $target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); return ($source->id != $target->id && isset($languages[$source->id]) && isset($languages[$target->id]) @@ -67,7 +67,7 @@ public function access(Route $route, Request $request, AccountInterface $account case 'update': case 'delete': $language = language_load($request->attributes->get('language')); - $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); + $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php index 03aedcb0433a31a6420308944fa688ac6257633e..35bb593947c05b84ca73f7aadca5da5ef78aefe4 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php @@ -26,7 +26,7 @@ public static function getInfo() { */ function testFileTokenReplacement() { $token_service = \Drupal::token(); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Create file field. $type_name = 'article'; diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 9d2305825bc066d6bb46ad2719dceaab26e7b6ea..f196969a879400226e2f424d0e61c4e158b5138a 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -402,7 +402,7 @@ function language_get_default_langcode($entity_type, $bundle) { } $default_value = NULL; - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); switch ($configuration['langcode']) { case 'site_default': $default_value = language_default()->id; diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php index 5b413f87cd13e130e024d3fe501eb9f265020366..adab4caeee1b8c2a969d3bf8496da082385c5386 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php @@ -83,7 +83,7 @@ public function testDefaultLangcode() { // Current interface. 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); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $this->assertEqual($langcode, $language_interface->id); // Site's default. diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index 38171374a7c2dab0b53b1e52e715d60da13f0ad3..42f2b0f65402f3737ebc22e997cbe53888b4dc7b 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -13,8 +13,8 @@ */ function language_test_page_build() { language_test_store_language_negotiation(); - 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))); + if (isset(\Drupal::languageManager()->getCurrentLanguage()->id) && isset(\Drupal::languageManager()->getCurrentLanguage()->method_id)) { + drupal_set_message(t('Language negotiation method: @name', array('@name' => \Drupal::languageManager()->getCurrentLanguage()->method_id))); } } diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 105f44ec0cbdc52262a2fedb3ed5f09bdacc746f..7c3f5706c1905fab8a34fb789101ff0c9dafa73f 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -315,7 +315,7 @@ function locale_translatable_language_list() { * plural formula. */ function locale_get_plural($count, $langcode = NULL) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Used to locally cache the plural formulas for all languages. $plural_formulas = &drupal_static(__FUNCTION__, array()); @@ -583,7 +583,7 @@ function locale_js_alter(&$javascript) { * applicable. */ function locale_js_translate(array $files = array()) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $dir = 'public://' . \Drupal::config('locale.settings')->get('javascript.directory'); $parsed = \Drupal::state()->get('system.javascript_parsed') ?: array(); @@ -644,7 +644,7 @@ function locale_library_alter(array &$library, $module, $name) { // the behavior executes early. JS_LIBRARY is the default. $library['dependencies'][] = array('locale', 'drupal.locale.datepicker'); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $settings['jquery']['ui']['datepicker'] = array( 'isRTL' => $language_interface->direction == Language::DIRECTION_RTL, 'firstDay' => \Drupal::config('system.date')->get('first_day'), @@ -820,7 +820,7 @@ function locale_system_file_system_settings_submit(&$form, $form_state) { */ function locale_preprocess_node(&$variables) { if ($variables['node']->language()->id != Language::LANGCODE_NOT_SPECIFIED) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $node_language = $variables['node']->language(); if ($node_language->id != $language_interface->id) { @@ -1270,7 +1270,7 @@ function _locale_invalidate_js($langcode = NULL) { function _locale_rebuild_js($langcode = NULL) { $config = \Drupal::config('locale.settings'); if (!isset($langcode)) { - $language = language(Language::TYPE_INTERFACE); + $language = \Drupal::languageManager()->getCurrentLanguage(); } else { // Get information about the locale. diff --git a/core/modules/node/node.module b/core/modules/node/node.module index bb851a5b60ce261a6b0a84b792734e087ea0339a..fb29b392825d0458cd0ed3a30804f388adb72b3d 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -336,7 +336,7 @@ function node_type_get_types() { * An array of node type labels, keyed by the node type name. */ function node_type_get_names() { - $cid = 'node_type:names:' . language(Language::TYPE_INTERFACE)->id; + $cid = 'node_type:names:' . \Drupal::languageManager()->getCurrentLanguage()->id; if ($cache = \Drupal::cache()->get($cid)) { return $cache->data; } @@ -1147,7 +1147,7 @@ function node_block_access($block) { */ function node_feed($nids = FALSE, $channel = array()) { global $base_url; - $language_content = language(Language::TYPE_CONTENT); + $language_content = \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $rss_config = \Drupal::config('system.rss'); if ($nids === FALSE) { diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index ec718554edada903a1ffe4fa70578b922b636ac5..34b235c650d741eddcd07e4d3c90facf424d1bca 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -31,7 +31,7 @@ function search_theme_suggestions_search_result(array $variables) { * - content_attributes: HTML attributes for the content. */ function template_preprocess_search_result(&$variables) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $result = $variables['result']; $variables['url'] = check_url($result['link']); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index cf162fd3baf2dd02c76c42e3dd63a9ddb9e4be9e..e1bcc90234f119da2934e70b122ef09d525418a5 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -973,7 +973,7 @@ private function prepareEnvironment() { // Create the database prefix for this test. $this->prepareDatabasePrefix(); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // When running the test runner within a test, back up the original database // prefix. diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php index f8fa0fe100169704b2de9a921f29ec2f6ecb895d..712c5ab21a4722b5c3cf2ce904e1038a5e4d3c7b 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php @@ -25,7 +25,7 @@ public static function getInfo() { * Creates a node, then tests the statistics tokens generated from it. */ function testStatisticsTokenReplacement() { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Create user and node. $user = $this->drupalCreateUser(array('create page content')); diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php index 8684406741efb2e75473c7e88090da2a38ec2dd9..ed6de6c50330802ba2ceb62e995e4ccc51cee031 100644 --- a/core/modules/system/language.api.php +++ b/core/modules/system/language.api.php @@ -25,7 +25,7 @@ * The current path. */ function hook_language_switch_links_alter(array &$links, $type, $path) { - $language_interface = language(\Drupal\Core\Language\Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); if ($type == \Drupal\Core\Language\Language::TYPE_CONTENT && isset($links[$language_interface->id])) { foreach ($links[$language_interface->id] as $link) { @@ -69,7 +69,7 @@ function hook_language_switch_links_alter(array &$links, $type, $path) { * Here is a code snippet to transliterate some text: * @code * // Use the current default interface language. - * $langcode = language(\Drupal\Core\Language\Language::TYPE_INTERFACE)->id; + * $langcode = \Drupal::languageManager()->getCurrentLanguage()->id; * // Instantiate the transliteration class. * $trans = \Drupal::transliteration(); * // Use this to transliterate some text. 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 4511346494a4ba25928cac0d9401c5a41fe7f52b..c9ac3bd22c71b8e41b65ef9917dd898094dd5036 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -96,7 +96,7 @@ function testAdminDefinedFormatDate() { function testFormatDate() { global $user; - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $timestamp = strtotime('2007-03-26T00:00:00+00:00'); $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test all parameters.'); 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 927b7b1e2384e0785ab91a8a3b65c899feec10a5..025c190db00c575a76644d7b185900ce87c59535 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php @@ -50,7 +50,7 @@ function setUp() { * Assert that the pluggable mail system is functional. */ public function testPluggableFramework() { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Use MailTestCase for sending a message. drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language_interface->id); @@ -65,7 +65,7 @@ public function testPluggableFramework() { * @see simpletest_mail_alter() */ public function testCancelMessage() { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Reset the class variable holding a copy of the last sent message. self::$sent_message = NULL; @@ -81,7 +81,7 @@ public function testCancelMessage() { * Checks the From: and Reply-to: headers. */ public function testFromAndReplyToHeader() { - global $language; + $language = \Drupal::languageManager()->getCurrentLanguage(); // Reset the class variable holding a copy of the last sent message. self::$sent_message = NULL; diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index cd5919c4a36d08739c10fda47ae49b93894ca38e..19ea5b1b75e2772116296b021305f5fe76bcded1 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -348,7 +348,7 @@ function hook_library_alter(array &$library, $extension, $name) { // hook_library_info_alter() already. $library['dependencies'][] = array('locale', 'drupal.locale.datepicker'); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $settings['jquery']['ui']['datepicker'] = array( 'isRTL' => $language_interface->direction == Language::DIRECTION_RTL, 'firstDay' => \Drupal::config('system.date')->get('first_day'), @@ -1388,7 +1388,7 @@ function hook_template_preprocess_default_variables_alter(&$variables) { */ function hook_watchdog(array $log_entry) { global $base_url; - $language_interface = language(\Drupal\Core\Language\Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $severity_list = array( WATCHDOG_EMERGENCY => t('Emergency'), diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 2580688af3ff22d4f1ebf0b14f80b2f837f63276..ef3749110d3a9bd283851028ec7b1bd25d9453cc 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1334,7 +1334,7 @@ function system_page_build(&$page) { array( 'path' => current_path(), 'front' => drupal_is_front_page(), - 'language' => language(\Drupal\Core\Language\Language::TYPE_URL)->id, + 'language' => \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\Language::TYPE_URL)->id, 'query' => \Drupal::service('request')->query->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 9928a5707141226c445aaf67f8fab9879bf955ba..29634e2294b73ab2addd8d1cd45bd3ed59fd9fff 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)->id, 'cache', 1542646800, array('plugin_test')); + $this->discovery = new CacheDecorator($this->discovery, 'mock_block:' . \Drupal::languageManager()->getCurrentLanguage()->id, 'cache', 1542646800, array('plugin_test')); } } diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index a5d617de822ae6f6bbbc2b9615c2656608aa0ac9..931707b9e16e76b2f793273b222263b266ca921b 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -258,7 +258,7 @@ function hook_theme_suggestions_HOOK(array $variables) { */ function hook_theme_suggestions_alter(array &$suggestions, array $variables, $hook) { // Add an interface-language specific suggestion to all theme hooks. - $suggestions[] = $hook . '__' . \Drupal::languageManager()->getLanguage()->id; + $suggestions[] = $hook . '__' . \Drupal::languageManager()->getCurrentLanguage()->id; } /** diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php index e22b97efc12ac3add39479ce0c33767748feefe1..eac5f8496b9e061ed06ec8bb78267b64f26950b0 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php @@ -66,7 +66,7 @@ function setUp() { */ function testTaxonomyTokenReplacement() { $token_service = \Drupal::token(); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Create two taxonomy terms. $term1 = $this->createTerm($this->vocabulary); diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php index 964c6642ae020a8cd03bc75c3a4d71c966f50abb..915e71f3cbd3bcbb37ce2e2fec282e167c247272 100644 --- a/core/modules/user/lib/Drupal/user/AccountFormController.php +++ b/core/modules/user/lib/Drupal/user/AccountFormController.php @@ -72,7 +72,7 @@ public function form(array $form, array &$form_state) { $user = $this->currentUser(); $config = \Drupal::config('user.settings'); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $register = $account->isAnonymous(); $admin = $user->hasPermission('administer users'); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php index cc706baef8131d9da0c346941b371e7629b7c727..d16b4e2e070d037c039fa1672f576e9a1a4fbaac 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php @@ -43,7 +43,7 @@ public function setUp() { */ function testUserTokenReplacement() { $token_service = \Drupal::token(); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $url_options = array( 'absolute' => TRUE, 'language' => $language_interface, 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 cfad8fe41e79dca4f58860e12e0c9f3ccaa48a59..665b7a51270996ba8221668014d17fa33d82537b 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 @@ -285,7 +285,7 @@ public function generateResultsKey() { 'build_info' => $build_info, 'roles' => $user->getRoles(), 'super-user' => $user->id() == 1, // special caching for super user. - 'langcode' => language(Language::TYPE_INTERFACE)->id, + 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, 'base_url' => $GLOBALS['base_url'], ); $request = \Drupal::request(); @@ -315,7 +315,7 @@ public function generateOutputKey() { 'roles' => $user->getRoles(), 'super-user' => $user->id() == 1, // special caching for super user. 'theme' => $GLOBALS['theme'], - 'langcode' => language(Language::TYPE_INTERFACE)->id, + 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, 'base_url' => $GLOBALS['base_url'], ); diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index d48f78957bc6e6f47f1d3c6388d75952a9840dd8..faacf8a69b8d9947288f86449f5c371dcb18d1c8 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -341,7 +341,7 @@ function hook_views_query_substitutions(ViewExecutable $view) { return array( '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***CURRENT_LANGUAGE***' => language(\Drupal\Core\Language\Language::TYPE_CONTENT)->id, + '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\Language::TYPE_CONTENT)->id, '***DEFAULT_LANGUAGE***' => language_default()->id, ); } diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 400fcf20cd6807a3f784daecd6e8a21d3170ef72..8a55f4bdbbc76b6f3a235b9fd43d7d00f10aed78 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -1017,7 +1017,7 @@ function template_preprocess_views_view_rss(&$variables) { $variables['link'] = check_url(url($path, $url_options)); } - $variables['langcode'] = String::checkPlain(language(Language::TYPE_INTERFACE)->id); + $variables['langcode'] = String::checkPlain(\Drupal::languageManager()->getCurrentLanguage()->id); $variables['namespaces'] = new Attribute($style->namespaces); $variables['items'] = $items; $variables['channel_elements'] = format_xml_elements($style->channel_elements); diff --git a/core/modules/views/views.views_execution.inc b/core/modules/views/views.views_execution.inc index e730bbb6e470cae91b610a0d2b6a42628ce798fa..18039befd34604a6d21d063211a5c97881853001 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***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***CURRENT_LANGUAGE***' => language(Language::TYPE_CONTENT)->id, + '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT)->id, '***DEFAULT_LANGUAGE***' => language_default()->id, ); }