Commit 9a0367fa authored by Dries's avatar Dries

- Patch #1719488 by effulgentsia: Rename language_manager() to language() and related cleanup.

parent 49e12de3
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Exception\RuntimeException as DependencyInjectionRuntimeException;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
...@@ -1457,7 +1458,7 @@ function t($string, array $args = array(), array $options = array()) { ...@@ -1457,7 +1458,7 @@ function t($string, array $args = array(), array $options = array()) {
// Merge in default. // Merge in default.
if (empty($options['langcode'])) { if (empty($options['langcode'])) {
$options['langcode'] = language_manager(LANGUAGE_TYPE_INTERFACE)->langcode; $options['langcode'] = language(LANGUAGE_TYPE_INTERFACE)->langcode;
} }
if (empty($options['context'])) { if (empty($options['context'])) {
$options['context'] = ''; $options['context'] = '';
...@@ -2600,13 +2601,13 @@ function get_t() { ...@@ -2600,13 +2601,13 @@ function get_t() {
/** /**
* Initializes all the defined language types. * Initializes all the defined language types.
* *
* @see language_manager() * @see language()
*/ */
function drupal_language_initialize() { function drupal_language_initialize() {
if (language_multilingual()) { if (language_multilingual()) {
$types = language_types_get_all(); $types = language_types_get_all();
foreach ($types as $type) { foreach ($types as $type) {
language_manager($type); language($type);
} }
// Allow modules to react on language system initialization in multilingual // Allow modules to react on language system initialization in multilingual
// environments. // environments.
...@@ -2615,56 +2616,61 @@ function drupal_language_initialize() { ...@@ -2615,56 +2616,61 @@ function drupal_language_initialize() {
} }
/** /**
* Initializes the passed in language type. * Returns the language object for a given language type.
* *
* The 'language_manager' service is only available within the scope of a kernel * The 'language_manager' service is only available within the scope of a kernel
* request. When it's not available, we return a default language object, * request. When it's not available, we return a default language object,
* regardless of the type passed in. * regardless of the type passed in.
* *
* Note that this function is provided for legacy code that needs to get e.g.
* the interface language outside the scope of a request. Code that runs within
* the scope of a request should call
* drupal_container()->get('language_manager')->getLanguage($type)
* directly.
*
* @see Drupal\Core\Language\LanguageManager * @see Drupal\Core\Language\LanguageManager
* *
* @param $type * @param $type
* The type of language object needed, e.g. LANGUAGE_TYPE_INTERFACE. Passing * The type of language object needed, e.g. LANGUAGE_TYPE_INTERFACE.
* NULL invokes a reset of the statically stored language type objects. * @param $reset
*/ * TRUE to reset the statically cached language object for the type, or for
function language_manager($type = NULL) { * all types if $type is NULL.
// Keep track of whether we are in a multilingual environment. */
static $multilingual = FALSE; function language($type, $reset = FALSE) {
// Keep track of whether the language_manager service is available. // We don't use drupal_static() here because resetting is not a simple case of
static $language_manager_service = FALSE; // drupal_static_reset().
if ($multilingual && $language_manager_service) { static $languages = array();
if (!$type) {
drupal_container()->get('language_manager')->reset(); // Reset the language manager's cache and our own.
return; if ($reset) {
}
return drupal_container()->get('language_manager')->getLanguage($type);
}
if (language_multilingual()) {
$multilingual = TRUE;
if (drupal_container()->has('language_manager')) { if (drupal_container()->has('language_manager')) {
$language_manager_service = TRUE; drupal_container()->get('language_manager')->reset($type);
return drupal_container()->get('language_manager')->getLanguage($type); }
if (!isset($type)) {
$languages = array();
}
elseif (isset($languages[$type])) {
unset($languages[$type]);
} }
} }
// We can't use drupal_static() here because resetting is not a simple case of
// drupal_static_reset(). // If no type is passed (most likely when resetting all types), return.
static $languages; if (!isset($type)) {
// If no type was passed in, reset the languages array. return;
if (!$type) { }
$languages = array();
// When the language_manager service exists (is both defined and the 'request'
// scope is active in the container), use it to get the language. Otherwise
// return the default language.
try {
$language_manager = drupal_container()->get('language_manager', Container::NULL_ON_INVALID_REFERENCE);
} }
// If this is not a multilingual environment or we have not yet entered the catch (DependencyInjectionRuntimeException $e) {
// request scope, just use the default language regardless of $type. }
if (!isset($languages[$type])) {
$languages[$type] = language_default(); if (isset($language_manager)) {
return $language_manager->getLanguage($type);
}
else {
if (!isset($languages[$type])) {
$languages[$type] = language_default();
}
return $languages[$type];
} }
return $languages[$type];
} }
/** /**
......
...@@ -1599,7 +1599,7 @@ function filter_xss_bad_protocol($string, $decode = TRUE) { ...@@ -1599,7 +1599,7 @@ function filter_xss_bad_protocol($string, $decode = TRUE) {
* Arbitrary elements may be added using the $args associative array. * Arbitrary elements may be added using the $args associative array.
*/ */
function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) { function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) {
$langcode = $langcode ? $langcode : language_manager(LANGUAGE_TYPE_CONTENT)->langcode; $langcode = $langcode ? $langcode : language(LANGUAGE_TYPE_CONTENT)->langcode;
$output = "<channel>\n"; $output = "<channel>\n";
$output .= ' <title>' . check_plain($title) . "</title>\n"; $output .= ' <title>' . check_plain($title) . "</title>\n";
...@@ -1901,7 +1901,7 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL ...@@ -1901,7 +1901,7 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
} }
if (empty($langcode)) { if (empty($langcode)) {
$langcode = language_manager(LANGUAGE_TYPE_INTERFACE)->langcode; $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
} }
switch ($type) { switch ($type) {
...@@ -2077,7 +2077,7 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) { ...@@ -2077,7 +2077,7 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
* - 'language': An optional language object. If the path being linked to is * - '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 * 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 * for the URL. If $options['language'] is omitted, the language will be
* obtained from language_manager(LANGUAGE_TYPE_URL). * obtained from language(LANGUAGE_TYPE_URL).
* - 'https': Whether this URL should point to a secure location. If not * - '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 * 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 * respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS can
...@@ -2322,7 +2322,7 @@ function l($text, $path, array $options = array()) { ...@@ -2322,7 +2322,7 @@ function l($text, $path, array $options = array()) {
// Append active class. // Append active class.
if (($path == current_path() || ($path == '<front>' && drupal_is_front_page())) && if (($path == current_path() || ($path == '<front>' && drupal_is_front_page())) &&
(empty($options['language']) || $options['language']->langcode == language_manager(LANGUAGE_TYPE_URL)->langcode)) { (empty($options['language']) || $options['language']->langcode == language(LANGUAGE_TYPE_URL)->langcode)) {
$options['attributes']['class'][] = 'active'; $options['attributes']['class'][] = 'active';
} }
...@@ -6017,7 +6017,7 @@ function drupal_render_cid_parts($granularity = NULL) { ...@@ -6017,7 +6017,7 @@ function drupal_render_cid_parts($granularity = NULL) {
// part. // part.
if (language_multilingual()) { if (language_multilingual()) {
foreach (language_types_get_configurable() as $language_type) { foreach (language_types_get_configurable() as $language_type) {
$cid_parts[] = language_manager($language_type)->langcode; $cid_parts[] = language($language_type)->langcode;
} }
} }
......
...@@ -1069,7 +1069,7 @@ function menu_tree_output($tree) { ...@@ -1069,7 +1069,7 @@ function menu_tree_output($tree) {
*/ */
function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) { function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
$tree = &drupal_static(__FUNCTION__, array()); $tree = &drupal_static(__FUNCTION__, array());
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
// Use $mlid as a flag for whether the data being loaded is for the whole tree. // Use $mlid as a flag for whether the data being loaded is for the whole tree.
$mlid = isset($link['mlid']) ? $link['mlid'] : 0; $mlid = isset($link['mlid']) ? $link['mlid'] : 0;
...@@ -1180,7 +1180,7 @@ function menu_tree_get_path($menu_name) { ...@@ -1180,7 +1180,7 @@ function menu_tree_get_path($menu_name) {
function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE) { function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE) {
$tree = &drupal_static(__FUNCTION__, array()); $tree = &drupal_static(__FUNCTION__, array());
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
// Check if the active trail has been overridden for this menu tree. // Check if the active trail has been overridden for this menu tree.
$active_path = menu_tree_get_path($menu_name); $active_path = menu_tree_get_path($menu_name);
...@@ -1336,7 +1336,7 @@ function menu_build_tree($menu_name, array $parameters = array()) { ...@@ -1336,7 +1336,7 @@ function menu_build_tree($menu_name, array $parameters = array()) {
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. // Static cache of already built menu trees.
$trees = &drupal_static(__FUNCTION__, array()); $trees = &drupal_static(__FUNCTION__, array());
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
// Build the cache id; sort parents to prevent duplicate storage and remove // Build the cache id; sort parents to prevent duplicate storage and remove
// default parameter values. // default parameter values.
......
...@@ -82,7 +82,7 @@ function drupal_lookup_path($action, $path = '', $langcode = NULL) { ...@@ -82,7 +82,7 @@ function drupal_lookup_path($action, $path = '', $langcode = NULL) {
// language. If we used a language different from the one conveyed by the // 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 // requested URL, we might end up being unable to check if there is a path
// alias matching the URL path. // alias matching the URL path.
$langcode = $langcode ? $langcode : language_manager(LANGUAGE_TYPE_URL)->langcode; $langcode = $langcode ? $langcode : language(LANGUAGE_TYPE_URL)->langcode;
if ($action == 'wipe') { if ($action == 'wipe') {
$cache = array(); $cache = array();
......
...@@ -1627,7 +1627,7 @@ function theme_link($variables) { ...@@ -1627,7 +1627,7 @@ function theme_link($variables) {
* http://www.w3.org/TR/WCAG-TECHS/H42.html for more information. * http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
*/ */
function theme_links($variables) { function theme_links($variables) {
$language_url = language_manager(LANGUAGE_TYPE_URL); $language_url = language(LANGUAGE_TYPE_URL);
$links = $variables['links']; $links = $variables['links'];
$attributes = $variables['attributes']; $attributes = $variables['attributes'];
...@@ -2398,7 +2398,7 @@ function _template_preprocess_default_variables() { ...@@ -2398,7 +2398,7 @@ function _template_preprocess_default_variables() {
* @see html.tpl.php * @see html.tpl.php
*/ */
function template_preprocess_html(&$variables) { function template_preprocess_html(&$variables) {
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
// Compile a list of classes that are going to be applied to the body element. // Compile a list of classes that are going to be applied to the body element.
// This allows advanced theming based on context (home page, node of certain type, etc.). // This allows advanced theming based on context (home page, node of certain type, etc.).
...@@ -2530,7 +2530,7 @@ function template_preprocess_html(&$variables) { ...@@ -2530,7 +2530,7 @@ function template_preprocess_html(&$variables) {
* @see page.tpl.php * @see page.tpl.php
*/ */
function template_preprocess_page(&$variables) { function template_preprocess_page(&$variables) {
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
$site_config = config('system.site'); $site_config = config('system.site');
// Move some variables to the top level for themer convenience and template cleanliness. // Move some variables to the top level for themer convenience and template cleanliness.
...@@ -2711,7 +2711,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') { ...@@ -2711,7 +2711,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
*/ */
function template_preprocess_maintenance_page(&$variables) { function template_preprocess_maintenance_page(&$variables) {
global $theme; global $theme;
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
// Retrieve the theme data to list all available regions. // Retrieve the theme data to list all available regions.
$theme_data = list_themes(); $theme_data = list_themes();
$regions = $theme_data[$theme]->info['regions']; $regions = $theme_data[$theme]->info['regions'];
......
...@@ -33,7 +33,7 @@ public function onRespond(FilterResponseEvent $event) { ...@@ -33,7 +33,7 @@ public function onRespond(FilterResponseEvent $event) {
// @todo Receive the LanguageManager object as a constructor argument when // @todo Receive the LanguageManager object as a constructor argument when
// the dependency injection container allows for it performantly: // the dependency injection container allows for it performantly:
// http://drupal.org/node/1706064. // http://drupal.org/node/1706064.
$response->headers->set('Content-language', language_manager(LANGUAGE_TYPE_INTERFACE)->langcode); $response->headers->set('Content-language', language(LANGUAGE_TYPE_INTERFACE)->langcode);
// Because pages are highly dynamic, set the last-modified time to now // Because pages are highly dynamic, set the last-modified time to now
// since the page is in fact being regenerated right now. // since the page is in fact being regenerated right now.
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
* *
* This service is dependent on the 'request' service and can therefore pass the * This service is dependent on the 'request' service and can therefore pass the
* Request object to the code that deals with each particular language type. * Request object to the code that deals with each particular language type.
* This means the Request can be used directly for things like url-based language * This means the Request can be used directly for things like url-based
* negotiation. * language negotiation.
*/ */
class LanguageManager { class LanguageManager {
...@@ -32,12 +32,22 @@ public function getLanguage($type) { ...@@ -32,12 +32,22 @@ public function getLanguage($type) {
} }
// @todo Objectify the language system so that we don't have to do this. // @todo Objectify the language system so that we don't have to do this.
include_once DRUPAL_ROOT . '/core/includes/language.inc'; if (language_multilingual()) {
$this->languages[$type] = language_types_initialize($type, $this->request); include_once DRUPAL_ROOT . '/core/includes/language.inc';
$this->languages[$type] = language_types_initialize($type, $this->request);
}
else {
$this->languages[$type] = language_default();
}
return $this->languages[$type]; return $this->languages[$type];
} }
function reset() { public function reset($type = NULL) {
$this->languages = array(); if (!isset($type)) {
$this->languages = array();
}
elseif (isset($this->languages[$type])) {
unset($this->languages[$type]);
}
} }
} }
...@@ -329,7 +329,7 @@ function hook_block_view_MODULE_DELTA_alter(&$data, $block) { ...@@ -329,7 +329,7 @@ function hook_block_view_MODULE_DELTA_alter(&$data, $block) {
*/ */
function hook_block_list_alter(&$blocks) { function hook_block_list_alter(&$blocks) {
global $theme_key; global $theme_key;
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
// This example shows how to achieve language specific visibility setting for // This example shows how to achieve language specific visibility setting for
// blocks. // blocks.
......
...@@ -880,7 +880,7 @@ function block_block_list_alter(&$blocks) { ...@@ -880,7 +880,7 @@ function block_block_list_alter(&$blocks) {
continue; continue;
} }
foreach ($block_langcodes[$block->module][$block->delta] as $language_type => $langcodes) { foreach ($block_langcodes[$block->module][$block->delta] as $language_type => $langcodes) {
if (isset($langcodes[language_manager($language_type)->langcode])) { if (isset($langcodes[language($language_type)->langcode])) {
// Found a language type - langcode combination in the configuration // Found a language type - langcode combination in the configuration
// that is applicable to the current request. // that is applicable to the current request.
continue 2; continue 2;
......
...@@ -1224,7 +1224,7 @@ function book_toc($bid, $depth_limit, $exclude = array()) { ...@@ -1224,7 +1224,7 @@ function book_toc($bid, $depth_limit, $exclude = array()) {
*/ */
function template_preprocess_book_export_html(&$variables) { function template_preprocess_book_export_html(&$variables) {
global $base_url; global $base_url;
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
$variables['title'] = check_plain($variables['title']); $variables['title'] = check_plain($variables['title']);
$variables['base_url'] = $base_url; $variables['base_url'] = $base_url;
......
...@@ -959,7 +959,7 @@ function comment_prepare_thread(&$comments) { ...@@ -959,7 +959,7 @@ function comment_prepare_thread(&$comments) {
*/ */
function comment_view(Comment $comment, Node $node, $view_mode = 'full', $langcode = NULL) { function comment_view(Comment $comment, Node $node, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) { if (!isset($langcode)) {
$langcode = language_manager(LANGUAGE_TYPE_CONTENT)->langcode; $langcode = language(LANGUAGE_TYPE_CONTENT)->langcode;
} }
// Populate $comment->content with a render() array. // Populate $comment->content with a render() array.
...@@ -1025,7 +1025,7 @@ function comment_view(Comment $comment, Node $node, $view_mode = 'full', $langco ...@@ -1025,7 +1025,7 @@ function comment_view(Comment $comment, Node $node, $view_mode = 'full', $langco
*/ */
function comment_build_content(Comment $comment, Node $node, $view_mode = 'full', $langcode = NULL) { function comment_build_content(Comment $comment, Node $node, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) { if (!isset($langcode)) {
$langcode = language_manager(LANGUAGE_TYPE_CONTENT)->langcode; $langcode = language(LANGUAGE_TYPE_CONTENT)->langcode;
} }
// Remove previously built content, if exists. // Remove previously built content, if exists.
...@@ -1683,7 +1683,7 @@ function comment_forms() { ...@@ -1683,7 +1683,7 @@ function comment_forms() {
*/ */
function comment_form($form, &$form_state, Comment $comment) { function comment_form($form, &$form_state, Comment $comment) {
global $user; global $user;
$language_content = language_manager(LANGUAGE_TYPE_CONTENT); $language_content = language(LANGUAGE_TYPE_CONTENT);
// During initial form build, add the comment entity to the form state for // During initial form build, add the comment entity to the form state for
// use during form building and processing. During a rebuild, use what is in // use during form building and processing. During a rebuild, use what is in
......
...@@ -23,7 +23,7 @@ public static function getInfo() { ...@@ -23,7 +23,7 @@ public static function getInfo() {
* Creates a comment, then tests the tokens generated from it. * Creates a comment, then tests the tokens generated from it.
*/ */
function testCommentTokenReplacement() { function testCommentTokenReplacement() {
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
$url_options = array( $url_options = array(
'absolute' => TRUE, 'absolute' => TRUE,
'language' => $language_interface, 'language' => $language_interface,
......
...@@ -150,7 +150,7 @@ function contact_site_form_validate($form, &$form_state) { ...@@ -150,7 +150,7 @@ function contact_site_form_validate($form, &$form_state) {
*/ */
function contact_site_form_submit($form, &$form_state) { function contact_site_form_submit($form, &$form_state) {
global $user; global $user;
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
$values = $form_state['values']; $values = $form_state['values'];
$values['sender'] = $user; $values['sender'] = $user;
...@@ -292,7 +292,7 @@ function contact_personal_form($form, &$form_state, $recipient) { ...@@ -292,7 +292,7 @@ function contact_personal_form($form, &$form_state, $recipient) {
*/ */
function contact_personal_form_submit($form, &$form_state) { function contact_personal_form_submit($form, &$form_state) {
global $user; global $user;
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
$values = $form_state['values']; $values = $form_state['values'];
$values['sender'] = $user; $values['sender'] = $user;
......
...@@ -48,7 +48,7 @@ function entity_modules_disabled() { ...@@ -48,7 +48,7 @@ function entity_modules_disabled() {
* @see hook_entity_info_alter() * @see hook_entity_info_alter()
*/ */
function entity_get_info($entity_type = NULL) { function entity_get_info($entity_type = NULL) {
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
// Use the advanced drupal_static() pattern, since this is called very often. // Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast; static $drupal_static_fast;
......
...@@ -67,7 +67,7 @@ function field_info_cache_clear() { ...@@ -67,7 +67,7 @@ function field_info_cache_clear() {
* @see _field_info_collate_types_reset() * @see _field_info_collate_types_reset()
*/ */
function _field_info_collate_types() { function _field_info_collate_types() {
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
// Use the advanced drupal_static() pattern, since this is called very often. // Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast; static $drupal_static_fast;
......
...@@ -258,7 +258,7 @@ function field_valid_language($langcode, $default = TRUE) { ...@@ -258,7 +258,7 @@ function field_valid_language($langcode, $default = TRUE) {
if (in_array($langcode, $languages)) { if (in_array($langcode, $languages)) {
return $langcode; return $langcode;
} }
return $default ? language_default()->langcode : language_manager(LANGUAGE_TYPE_CONTENT)->langcode; return $default ? language_default()->langcode : language(LANGUAGE_TYPE_CONTENT)->langcode;
} }
/** /**
......
...@@ -23,7 +23,7 @@ public static function getInfo() { ...@@ -23,7 +23,7 @@ public static function getInfo() {
* Creates a file, then tests the tokens generated from it. * Creates a file, then tests the tokens generated from it.
*/ */
function testFileTokenReplacement() { function testFileTokenReplacement() {
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
$url_options = array( $url_options = array(
'absolute' => TRUE, 'absolute' => TRUE,
'language' => $language_interface, 'language' => $language_interface,
......
...@@ -399,7 +399,7 @@ function filter_modules_disabled($modules) { ...@@ -399,7 +399,7 @@ function filter_modules_disabled($modules) {
* @see filter_formats_reset() * @see filter_formats_reset()
*/ */
function filter_formats($account = NULL) { function filter_formats($account = NULL) {
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
$formats = &drupal_static(__FUNCTION__, array()); $formats = &drupal_static(__FUNCTION__, array());
// All available formats are cached for performance. // All available formats are cached for performance.
......
...@@ -965,7 +965,7 @@ function image_style_path($style_name, $uri) { ...@@ -965,7 +965,7 @@ function image_style_path($style_name, $uri) {
* @see image_effect_definition_load() * @see image_effect_definition_load()
*/ */
function image_effect_definitions() { function image_effect_definitions() {
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
// hook_image_effect_info() includes translated strings, so each language is // hook_image_effect_info() includes translated strings, so each language is
// cached separately. // cached separately.
......
...@@ -243,7 +243,7 @@ function language_delete($langcode) { ...@@ -243,7 +243,7 @@ function language_delete($langcode) {
* and checks to see if a related right to left CSS file should be included. * and checks to see if a related right to left CSS file should be included.
*/ */
function language_css_alter(&$css) { function language_css_alter(&$css) {
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
// If the current language is RTL, add the CSS file with the RTL overrides. // If the current language is RTL, add the CSS file with the RTL overrides.
if ($language_interface->direction == LANGUAGE_RTL) { if ($language_interface->direction == LANGUAGE_RTL) {
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
* The current interface language code. * The current interface language code.
*/ */
function language_from_interface() { function language_from_interface() {
return language_manager(LANGUAGE_TYPE_INTERFACE)->langcode; return language(LANGUAGE_TYPE_INTERFACE)->langcode;
} }
/** /**
...@@ -304,7 +304,7 @@ function language_url_fallback($language = NULL, $request = NULL, $language_type ...@@ -304,7 +304,7 @@ function language_url_fallback($language = NULL, $request = NULL, $language_type
return $default->langcode; return $default->langcode;
} }
else { else {
$langcode = language_manager($language_type)->langcode; $langcode = language($language_type)->langcode;
return $langcode; return $langcode;
} }
} }
...@@ -335,7 +335,7 @@ function language_switcher_url($type, $path) { ...@@ -335,7 +335,7 @@ function language_switcher_url($type, $path) {
*/ */
function language_switcher_session($type, $path) { function language_switcher_session($type, $path) {
$param = variable_get('language_negotiation_session_param', 'language'); $param = variable_get('language_negotiation_session_param', 'language');
$language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : language_manager($type)->langcode; $language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : language($type)->langcode;