Commit 1cd28eb4 authored by katbailey's avatar katbailey

Using the language_manager wrapper function to return a language whether or...

Using the language_manager wrapper function to return a language whether or not we're in the requet scope
parent 2f6b442d
......@@ -1458,7 +1458,7 @@ function t($string, array $args = array(), array $options = array()) {
// Merge in default.
if (empty($options['langcode'])) {
$options['langcode'] = drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode;
$options['langcode'] = language_manager(LANGUAGE_TYPE_INTERFACE)->langcode;
}
if (empty($options['context'])) {
$options['context'] = '';
......@@ -2442,7 +2442,7 @@ function drupal_get_bootstrap_phase() {
* $container->register(LANGUAGE_TYPE_INTERFACE, 'Drupal\\Core\\Language\\Language');
*
* // Retrieve the LANGUAGE_TYPE_INTERFACE object.
* $language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
* $language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
* @endcode
*
* @param $reset
......@@ -2489,36 +2489,6 @@ function drupal_container(Container $reset = NULL) {
// Register configuration object factory.
$container->register('config.factory', 'Drupal\Core\Config\ConfigFactory')
->addArgument(new Reference('config.storage.dispatcher'));
// Ensure a language object is registered for each language type, whether the
// site is multilingual or not.
$types = language_types_get_all();
if (language_multilingual()) {
include_once DRUPAL_ROOT . '/core/includes/language.inc';
foreach ($types as $type) {
$language = language_types_initialize($type);
// We cannot pass an object as a parameter to a method on a service.
$info = get_object_vars($language);
$container->set($type, NULL);
$container->register($type, 'Drupal\\Core\\Language\\Language')
->addMethodCall('extend', array($info));
}
}
else {
$info = variable_get('language_default', array(
'langcode' => 'en',
'name' => 'English',
'direction' => 0,
'weight' => 0,
'locked' => 0,
));
$info['default'] = TRUE;
foreach ($types as $type) {
$container->set($type, NULL);
$container->register($type, 'Drupal\\Core\\Language\\Language')
->addMethodCall('extend', array($info));
}
}
}
return $container;
}
......@@ -2666,16 +2636,52 @@ function get_t() {
/**
* Initializes all the defined language types.
*
* @see Drupal\Core\Language\Language
* @see language_manager()
*/
function drupal_language_initialize() {
if (language_multilingual()) {
$types = language_types_get_all();
include_once DRUPAL_ROOT . '/core/includes/language.inc';
foreach ($types as $type) {
language_manager($type);
}
// Allow modules to react on language system initialization in multilingual
// environments.
bootstrap_invoke_all('language_init');
}
}
/**
* Initializes the passed in language type.
*
* 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,
* regardless of the type passed in.
*
* @see Drupal\Core\Language\LanguageManager
*/
function language_manager($type) {
static $default_language;
static $initiated = FALSE; // Whether the language_manager has been initiated.
$languages = &drupal_static(__FUNCTION__, array());
if ($initiated) {
if (!isset($languages[$type])) {
$languages[$type] = drupal_container()->get('language_manager')->getLanguage($type);
}
return $languages[$type];
}
if (drupal_container()->has('language_manager')) {
$initiated = TRUE;
$languages[$type] = drupal_container()->get('language_manager')->getLanguage($type);
return $languages[$type];
}
if (isset($default_language)) {
return $default_language;
}
$default_language = language_default();
return $default_language;
}
/**
* Returns an array of the available language types.
*/
......
......@@ -1599,7 +1599,7 @@ function filter_xss_bad_protocol($string, $decode = TRUE) {
* 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 : drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode;
$langcode = $langcode ? $langcode : language_manager(LANGUAGE_TYPE_CONTENT)->langcode;
$output = "<channel>\n";
$output .= ' <title>' . check_plain($title) . "</title>\n";
......@@ -1901,7 +1901,7 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
}
if (empty($langcode)) {
$langcode = drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode;
$langcode = language_manager(LANGUAGE_TYPE_INTERFACE)->langcode;
}
switch ($type) {
......@@ -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
* 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 drupal_container()->get(LANGUAGE_TYPE_URL).
* obtained from language_manager(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
......@@ -2322,7 +2322,7 @@ function l($text, $path, array $options = array()) {
// Append active class.
if (($path == current_path() || ($path == '<front>' && drupal_is_front_page())) &&
(empty($options['language']) || $options['language']->langcode == drupal_container()->get(LANGUAGE_TYPE_URL)->langcode)) {
(empty($options['language']) || $options['language']->langcode == language_manager(LANGUAGE_TYPE_URL)->langcode)) {
$options['attributes']['class'][] = 'active';
}
......@@ -6012,7 +6012,7 @@ function drupal_render_cid_parts($granularity = NULL) {
// part.
if (language_multilingual()) {
foreach (language_types_get_configurable() as $language_type) {
$cid_parts[] = drupal_container()->get($language_type)->langcode;
$cid_parts[] = language_manager($language_type)->langcode;
}
}
......
......@@ -110,7 +110,7 @@
* @return
* The negotiated language object.
*/
function language_types_initialize($type) {
function language_types_initialize($type, $args = array()) {
// Execute the language negotiation methods in the order they were set up and
// return the first valid language found.
$negotiation = variable_get("language_negotiation_$type", array());
......@@ -120,6 +120,7 @@ function language_types_initialize($type) {
if (isset($method['types']) && !in_array($type, $method['types'])) {
continue;
}
$method['args'] = $args;
$language = language_negotiation_method_invoke($method_id, $method);
if ($language) {
// Remember the method ID used to detect the language.
......@@ -452,7 +453,8 @@ function language_negotiation_method_invoke($method_id, $method = NULL) {
// satisfied we can execute the callback.
$cache = !isset($method['cache']) || $user->uid || $method['cache'] == variable_get('cache', 0);
$callback = isset($method['callbacks']['negotiation']) ? $method['callbacks']['negotiation'] : FALSE;
$langcode = $cache && function_exists($callback) ? $callback($languages) : FALSE;
$args = isset($method['args']) ? $method['args'] : array();
$langcode = $cache && function_exists($callback) ? $callback($languages, $args) : FALSE;
$results[$method_id] = isset($languages[$langcode]) ? $languages[$langcode] : FALSE;
}
......
......@@ -1069,7 +1069,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 = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// Use $mlid as a flag for whether the data being loaded is for the whole tree.
$mlid = isset($link['mlid']) ? $link['mlid'] : 0;
......@@ -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) {
$tree = &drupal_static(__FUNCTION__, array());
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// Check if the active trail has been overridden for this menu tree.
$active_path = menu_tree_get_path($menu_name);
......@@ -1336,7 +1336,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 = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// Build the cache id; sort parents to prevent duplicate storage and remove
// default parameter values.
......
......@@ -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
// requested URL, we might end up being unable to check if there is a path
// alias matching the URL path.
$langcode = $langcode ? $langcode : drupal_container()->get(LANGUAGE_TYPE_URL)->langcode;
$langcode = $langcode ? $langcode : language_manager(LANGUAGE_TYPE_URL)->langcode;
if ($action == 'wipe') {
$cache = array();
......
......@@ -1624,7 +1624,7 @@ function theme_link($variables) {
* http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
*/
function theme_links($variables) {
$language_url = drupal_container()->get(LANGUAGE_TYPE_URL);
$language_url = language_manager(LANGUAGE_TYPE_URL);
$links = $variables['links'];
$attributes = $variables['attributes'];
......@@ -2395,7 +2395,7 @@ function _template_preprocess_default_variables() {
* @see html.tpl.php
*/
function template_preprocess_html(&$variables) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// 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.).
......@@ -2527,7 +2527,7 @@ function template_preprocess_html(&$variables) {
* @see page.tpl.php
*/
function template_preprocess_page(&$variables) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
$site_config = config('system.site');
// Move some variables to the top level for themer convenience and template cleanliness.
......@@ -2708,7 +2708,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
*/
function template_preprocess_maintenance_page(&$variables) {
global $theme;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// Retrieve the theme data to list all available regions.
$theme_data = list_themes();
$regions = $theme_data[$theme]->info['regions'];
......
......@@ -30,7 +30,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', drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode);
$response->headers->set('Content-language', language_manager(LANGUAGE_TYPE_INTERFACE)->langcode);
// Because pages are highly dynamic, set the last-modified time to now
// since the page is in fact being regenerated right now.
......
......@@ -21,9 +21,5 @@ public function extractPath(Request $request) {
public function setPath(Request $request, $path) {
$request->attributes->set('system_path', $path);
// @todo Remove this line once code has been refactored to use the request
// object directly.
_current_path($path);
}
}
......@@ -80,7 +80,6 @@ public function onKernelRequestLanguageResolve(GetResponseEvent $event) {
// @todo Decouple the above, but for now, invoke it and update the path
// prior to front page and alias resolution. When above is decoupled, also
// add 'langcode' (determined from $request only) to $request->attributes.
_current_path($path);
drupal_language_initialize();
$path = _current_path();
......
......@@ -44,8 +44,8 @@ public function __construct(array $options = array()) {
*
* @todo Remove this function once $GLOBALS['language'] is gone.
*/
public function extend($info) {
$vars = is_array($info) ? $info : get_object_vars($info);
public function extend($obj) {
$vars = get_object_vars($obj);
foreach ($vars as $var => $value) {
$this->$var = $value;
}
......
......@@ -16,22 +16,19 @@ class LanguageManager {
private $container;
public function __construct(Request $request) {
public function __construct(Request $request = NULL) {
$this->request = $request;
}
public function interfaceLanguage() {
$language = language_types_initialize(LANGUAGE_TYPE_INTERFACE);
return $language;
}
public function getLanguage($type) {
if (language_multilingual()) {
$language = language_types_initialize($type, array('request' => $this->request));
}
else {
$language = language_default();
}
public function contentLanguage() {
$language = language_types_initialize(LANGUAGE_TYPE_CONTENT);
return $language;
}
public function urlLanguage() {
$language = language_types_initialize(LANGUAGE_TYPE_URL);
return $language;
}
}
\ No newline at end of file
......@@ -329,7 +329,7 @@ function hook_block_view_MODULE_DELTA_alter(&$data, $block) {
*/
function hook_block_list_alter(&$blocks) {
global $theme_key;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// This example shows how to achieve language specific visibility setting for
// blocks.
......
......@@ -880,7 +880,7 @@ function block_block_list_alter(&$blocks) {
continue;
}
foreach ($block_langcodes[$block->module][$block->delta] as $language_type => $langcodes) {
if (isset($langcodes[drupal_container()->get($language_type)->langcode])) {
if (isset($langcodes[language_manager($language_type)->langcode])) {
// Found a language type - langcode combination in the configuration
// that is applicable to the current request.
continue 2;
......
......@@ -1224,7 +1224,7 @@ function book_toc($bid, $depth_limit, $exclude = array()) {
*/
function template_preprocess_book_export_html(&$variables) {
global $base_url;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
$variables['title'] = check_plain($variables['title']);
$variables['base_url'] = $base_url;
......
......@@ -958,7 +958,7 @@ function comment_prepare_thread(&$comments) {
*/
function comment_view(Comment $comment, Node $node, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode;
$langcode = language_manager(LANGUAGE_TYPE_CONTENT)->langcode;
}
// Populate $comment->content with a render() array.
......@@ -1024,7 +1024,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) {
if (!isset($langcode)) {
$langcode = drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode;
$langcode = language_manager(LANGUAGE_TYPE_CONTENT)->langcode;
}
// Remove previously built content, if exists.
......@@ -1682,7 +1682,7 @@ function comment_forms() {
*/
function comment_form($form, &$form_state, Comment $comment) {
global $user;
$language_content = drupal_container()->get(LANGUAGE_TYPE_CONTENT);
$language_content = language_manager(LANGUAGE_TYPE_CONTENT);
// 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
......
......@@ -23,7 +23,7 @@ public static function getInfo() {
* Creates a comment, then tests the tokens generated from it.
*/
function testCommentTokenReplacement() {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
......
......@@ -150,7 +150,7 @@ function contact_site_form_validate($form, &$form_state) {
*/
function contact_site_form_submit($form, &$form_state) {
global $user;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
$values = $form_state['values'];
$values['sender'] = $user;
......@@ -292,7 +292,7 @@ function contact_personal_form($form, &$form_state, $recipient) {
*/
function contact_personal_form_submit($form, &$form_state) {
global $user;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
$values = $form_state['values'];
$values['sender'] = $user;
......
......@@ -46,7 +46,7 @@ function entity_modules_disabled() {
* @see hook_entity_info_alter()
*/
function entity_get_info($entity_type = NULL) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
......
......@@ -67,7 +67,7 @@ function field_info_cache_clear() {
* @see _field_info_collate_types_reset()
*/
function _field_info_collate_types() {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
......
......@@ -258,7 +258,7 @@ function field_valid_language($langcode, $default = TRUE) {
if (in_array($langcode, $languages)) {
return $langcode;
}
return $default ? language_default()->langcode : drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode;
return $default ? language_default()->langcode : language_manager(LANGUAGE_TYPE_CONTENT)->langcode;
}
/**
......
......@@ -23,7 +23,7 @@ public static function getInfo() {
* Creates a file, then tests the tokens generated from it.
*/
function testFileTokenReplacement() {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
......
......@@ -399,7 +399,7 @@ function filter_modules_disabled($modules) {
* @see filter_formats_reset()
*/
function filter_formats($account = NULL) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
$formats = &drupal_static(__FUNCTION__, array());
// All available formats are cached for performance.
......
......@@ -965,7 +965,7 @@ function image_style_path($style_name, $uri) {
* @see image_effect_definition_load()
*/
function image_effect_definitions() {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// hook_image_effect_info() includes translated strings, so each language is
// cached separately.
......
......@@ -243,7 +243,7 @@ function language_delete($langcode) {
* and checks to see if a related right to left CSS file should be included.
*/
function language_css_alter(&$css) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// If the current language is RTL, add the CSS file with the RTL overrides.
if ($language_interface->direction == LANGUAGE_RTL) {
......
......@@ -52,7 +52,7 @@
* The current interface language code.
*/
function language_from_interface() {
return drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode;
return language_manager(LANGUAGE_TYPE_INTERFACE)->langcode;
}
/**
......@@ -200,7 +200,7 @@ function language_from_session($languages) {
* @return
* A valid language code on success, FALSE otherwise.
*/
function language_from_url($languages) {
function language_from_url($languages, $args = array()) {
$language_url = FALSE;
if (!language_negotiation_method_enabled(LANGUAGE_NEGOTIATION_URL)) {
......@@ -212,7 +212,19 @@ function language_from_url($languages) {
// Language negotiation happens before the public function current_path()
// is available.
// @todo Refactor with Symfony's Request object.
list($language, $path) = language_url_split_prefix(_current_path(), $languages);
if (isset($args['request'])) {
$request = $args['request'];
$current_path = $request->attributes->get('system_path');
if (!isset($current_path)) {
$current_path = trim($request->getPathInfo(), '/');
}
}
else {
$current_path = _current_path();
}
list($language, $path) = language_url_split_prefix($current_path, $languages);
_current_path($path);
if ($language !== FALSE) {
$language_url = $language->langcode;
......@@ -278,7 +290,7 @@ function language_from_url($languages) {
* @return
* A valid language code.
*/
function language_url_fallback($language = NULL, $language_type = LANGUAGE_TYPE_INTERFACE) {
function language_url_fallback($language = NULL, $args = array(), $language_type = LANGUAGE_TYPE_INTERFACE) {
$default = language_default();
$prefix = (variable_get('language_negotiation_url_part', LANGUAGE_NEGOTIATION_URL_PREFIX) == LANGUAGE_NEGOTIATION_URL_PREFIX);
......@@ -291,7 +303,8 @@ function language_url_fallback($language = NULL, $language_type = LANGUAGE_TYPE_
return $default->langcode;
}
else {
return drupal_container()->get($language_type)->langcode;
$langcode = language_manager($language_type)->langcode;
return $langcode;
}
}
......@@ -321,7 +334,7 @@ function language_switcher_url($type, $path) {
*/
function language_switcher_session($type, $path) {
$param = variable_get('language_negotiation_session_param', 'language');
$language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : drupal_container()->get($type)->langcode;
$language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : language_manager($type)->langcode;
$languages = language_list();
$links = array();
......@@ -364,7 +377,7 @@ function language_url_rewrite_url(&$path, &$options) {
// Language can be passed as an option, or we go for current URL language.
if (!isset($options['language'])) {
$language_url = drupal_container()->get(LANGUAGE_TYPE_URL);
$language_url = language_manager(LANGUAGE_TYPE_URL);
$options['language'] = $language_url;
}
// We allow only enabled languages here.
......
......@@ -26,9 +26,8 @@ public static function getInfo() {
function setUp() {
parent::setUp('language');
// Set up a new container to ensure we are building a new Language object
// for each test.
drupal_container(new ContainerBuilder());
// Ensure we are building a new Language object for each test.
drupal_static_reset('language_manager');
}
......@@ -42,7 +41,7 @@ function testDependencyInjectedNewLanguage() {
drupal_language_initialize();
$expected = language_default();
$result = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$result = language_manager(LANGUAGE_TYPE_INTERFACE);
foreach ($expected as $property => $value) {
$this->assertEqual($expected->$property, $result->$property, t('The dependency injected language object %prop property equals the new Language object %prop property.', array('%prop' => $property)));
}
......@@ -71,7 +70,7 @@ function testDependencyInjectedNewDefaultLanguage() {
// The langauge system creates a Language object which contains the
// same properties as the new default language object.
$expected = new Language($new_language_default);
$result = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$result = language_manager(LANGUAGE_TYPE_INTERFACE);
foreach ($expected as $property => $value) {
$this->assertEqual($expected->$property, $result->$property, t('The dependency injected language object %prop property equals the default language object %prop property.', array('%prop' => $property)));
}
......
......@@ -22,8 +22,8 @@ function language_test_boot() {
*/
function language_test_init() {
language_test_store_language_negotiation();
if (isset(drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode) && isset(drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->method_id)) {
drupal_set_message(t('Language negotiation method: @name', array('@name' => drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->method_id)));
if (isset(language_manager(LANGUAGE_TYPE_INTERFACE)->langcode) && isset(language_manager(LANGUAGE_TYPE_INTERFACE)->method_id)) {
drupal_set_message(t('Language negotiation method: @name', array('@name' => language_manager(LANGUAGE_TYPE_INTERFACE)->method_id)));
}
}
......@@ -95,7 +95,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] = drupal_container()->get($type)->langcode;
$last[$type] = language_manager($type)->langcode;
}
variable_set('language_test_language_negotiation_last', $last);
}
......
......@@ -49,7 +49,7 @@ function testUninstallProcess() {
// Check the UI language.
drupal_language_initialize();
$this->assertEqual(drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode, $this->langcode, t('Current language: %lang', array('%lang' => drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode)));
$this->assertEqual(language_manager(LANGUAGE_TYPE_INTERFACE)->langcode, $this->langcode, t('Current language: %lang', array('%lang' => language_manager(LANGUAGE_TYPE_INTERFACE)->langcode)));
// Enable multilingual workflow option for articles.
variable_set('node_type_language_hidden_article',FALSE);
......@@ -94,7 +94,7 @@ function testUninstallProcess() {
// Check the init language logic.
drupal_language_initialize();
$this->assertEqual(drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode)));
$this->assertEqual(language_manager(LANGUAGE_TYPE_INTERFACE)->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => language_manager(LANGUAGE_TYPE_INTERFACE)->langcode)));
// Check JavaScript files deletion.
$this->assertTrue($result = !file_exists($js_file), t('JavaScript file deleted: %file', array('%file' => $result ? $js_file : t('found'))));
......
......@@ -232,7 +232,7 @@ function locale_language_delete($language) {
* Language code to use for the lookup.
*/
function locale($string = NULL, $context = NULL, $langcode = NULL) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
......@@ -280,7 +280,7 @@ function locale_reset() {
* plural formula.
*/
function locale_get_plural($count, $langcode = NULL) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// Used to locally cache the plural formulas for all languages.
$plural_formulas = &drupal_static(__FUNCTION__, array());
......@@ -366,7 +366,7 @@ function locale_system_update($components) {
* file if necessary, and adds it to the page.
*/
function locale_js_alter(&$javascript) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
$dir = 'public://' . variable_get('locale_js_directory', 'languages');
$parsed = variable_get('javascript_parsed', array());
......@@ -426,7 +426,7 @@ function locale_js_alter(&$javascript) {
*/
function locale_library_info_alter(&$libraries, $module) {
if ($module == 'system' && isset($libraries['jquery.ui.datepicker'])) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
// locale.datepicker.js should be added in the JS_LIBRARY group, so that
// this attach behavior will execute early. JS_LIBRARY is the default for
// hook_library_info_alter(), thus does not have to be specified explicitly.
......@@ -572,7 +572,7 @@ function locale_form_system_file_system_settings_alter(&$form, $form_state) {
*/
function locale_preprocess_node(&$variables) {
if ($variables['langcode'] != LANGUAGE_NOT_SPECIFIED) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
$node_language = language_load($variables['langcode']);
if ($node_language->langcode != $language_interface->langcode) {
......@@ -771,7 +771,7 @@ function _locale_invalidate_js($langcode = NULL) {
*/
function _locale_rebuild_js($langcode = NULL) {
if (!isset($langcode)) {
$language = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language = language_manager(LANGUAGE_TYPE_INTERFACE);
}
else {
// Get information about the locale.
......
......@@ -103,7 +103,7 @@ function locale_translate_filters() {
}
// Pick the current interface language code for the filter.
$default_langcode = drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode;
$default_langcode = language_manager(LANGUAGE_TYPE_INTERFACE)->langcode;
if (!isset($language_options[$default_langcode])) {
$available_langcodes = array_keys($language_options);
$default_langcode = array_shift($available_langcodes);
......
......@@ -23,7 +23,7 @@ public static function getInfo() {
* Creates a node, then tests the tokens generated from it.
*/
function testNodeTokenReplacement() {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language_manager(LANGUAGE_TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
......
......@@ -672,7 +672,7 @@ function node_field_extra_fields() {