Commit a58940f1 authored by Dries's avatar Dries

- Patch #1222194 by Gábor Hojtsy, plach: rename global to ().

parent edabf1fc
......@@ -183,7 +183,7 @@
/**
* The type of language used to select the user interface.
*/
const LANGUAGE_TYPE_INTERFACE = 'language';
const LANGUAGE_TYPE_INTERFACE = 'language_interface';
/**
* The type of language used for URLs.
......@@ -1518,12 +1518,12 @@ function drupal_unpack($obj, $field = 'data') {
* @ingroup sanitization
*/
function t($string, array $args = array(), array $options = array()) {
global $language;
global $language_interface;
static $custom_strings;
// Merge in default.
if (empty($options['langcode'])) {
$options['langcode'] = isset($language->langcode) ? $language->langcode : LANGUAGE_SYSTEM;
$options['langcode'] = isset($language_interface->langcode) ? $language_interface->langcode : LANGUAGE_SYSTEM;
}
if (empty($options['context'])) {
$options['context'] = '';
......
......@@ -1892,9 +1892,9 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
}
// Use the default langcode if none is set.
global $language;
global $language_interface;
if (empty($langcode)) {
$langcode = isset($language->langcode) ? $language->langcode : LANGUAGE_SYSTEM;
$langcode = isset($language_interface->langcode) ? $language_interface->langcode : LANGUAGE_SYSTEM;
}
switch ($type) {
......@@ -2496,8 +2496,8 @@ function drupal_deliver_html_page($page_callback_result) {
}
// Send appropriate HTTP-Header for browsers and search engines.
global $language;
drupal_add_http_header('Content-Language', $language->langcode);
global $language_interface;
drupal_add_http_header('Content-Language', $language_interface->langcode);
// Menu status constants are integers; page content is a string or array.
if (is_int($page_callback_result)) {
......
......@@ -112,8 +112,8 @@
* The current interface language code.
*/
function locale_language_from_interface() {
global $language;
return isset($language->langcode) ? $language->langcode : FALSE;
global $language_interface;
return isset($language_interface->langcode) ? $language_interface->langcode : FALSE;
}
/**
......@@ -553,8 +553,6 @@ function locale_string_is_safe($string) {
* Drupal.formatPlural() and inserts them into the database.
*/
function _locale_parse_js_file($filepath) {
global $language;
// The file path might contain a query string, so make sure we only use the
// actual file.
$parsed_url = drupal_parse_url($filepath);
......@@ -708,12 +706,13 @@ function _locale_invalidate_js($langcode = NULL) {
/**
* (Re-)Creates the JavaScript translation file for a language.
*
* @param $language
* @param $langcode
* The language, the translation file should be (re)created for.
*/
function _locale_rebuild_js($langcode = NULL) {
if (!isset($langcode)) {
global $language;
global $language_interface;
$language = $language_interface;
}
else {
// Get information about the locale.
......
......@@ -1092,7 +1092,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
// Use $mlid as a flag for whether the data being loaded is for the whole tree.
$mlid = isset($link['mlid']) ? $link['mlid'] : 0;
// Generate a cache ID (cid) specific for this $menu_name, $link, $language, and depth.
$cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $GLOBALS['language']->langcode . ':' . (int) $max_depth;
$cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $GLOBALS['language_interface']->langcode . ':' . (int) $max_depth;
if (!isset($tree[$cid])) {
// If the static variable doesn't have the data, check {cache_menu}.
......@@ -1206,7 +1206,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
$max_depth = min($max_depth, MENU_MAX_DEPTH);
}
// Generate a cache ID (cid) specific for this page.
$cid = 'links:' . $menu_name . ':page:' . $item['href'] . ':' . $GLOBALS['language']->langcode . ':' . (int) $item['access'] . ':' . (int) $max_depth;
$cid = 'links:' . $menu_name . ':page:' . $item['href'] . ':' . $GLOBALS['language_interface']->langcode . ':' . (int) $item['access'] . ':' . (int) $max_depth;
// If we are asked for the active trail only, and $menu_name has not been
// built and cached for this page yet, then this likely means that it
// won't be built anymore, as this function is invoked from
......@@ -1358,7 +1358,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) {
if (isset($parameters['expanded'])) {
sort($parameters['expanded']);
}
$tree_cid = 'links:' . $menu_name . ':tree-data:' . $GLOBALS['language']->langcode . ':' . hash('sha256', serialize($parameters));
$tree_cid = 'links:' . $menu_name . ':tree-data:' . $GLOBALS['language_interface']->langcode . ':' . hash('sha256', serialize($parameters));
// If we do not have this tree in the static cache, check {cache_menu}.
if (!isset($trees[$tree_cid])) {
......
......@@ -2500,8 +2500,8 @@ function template_preprocess_html(&$variables) {
$variables['body_attributes_array'] = array();
// HTML element attributes.
$variables['html_attributes_array']['lang'] = $GLOBALS['language']->langcode;
$variables['html_attributes_array']['dir'] = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
$variables['html_attributes_array']['lang'] = $GLOBALS['language_interface']->langcode;
$variables['html_attributes_array']['dir'] = $GLOBALS['language_interface']->direction ? 'rtl' : 'ltr';
// Add favicon.
if (theme_get_setting('toggle_favicon')) {
......@@ -2571,8 +2571,8 @@ function template_preprocess_page(&$variables) {
$variables['base_path'] = base_path();
$variables['front_page'] = url();
$variables['feed_icons'] = drupal_get_feeds();
$variables['language'] = $GLOBALS['language'];
$variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
$variables['language'] = $GLOBALS['language_interface'];
$variables['language']->dir = $GLOBALS['language_interface']->direction ? 'rtl' : 'ltr';
$variables['logo'] = theme_get_setting('logo');
$variables['main_menu'] = theme_get_setting('toggle_main_menu') ? menu_main_menu() : array();
$variables['secondary_menu'] = theme_get_setting('toggle_secondary_menu') ? menu_secondary_menu() : array();
......@@ -2774,7 +2774,7 @@ function template_preprocess_maintenance_page(&$variables) {
}
// set the default language if necessary
$language = isset($GLOBALS['language']) ? $GLOBALS['language'] : language_default();
$language = isset($GLOBALS['language_interface']) ? $GLOBALS['language_interface'] : language_default();
$variables['head_title_array'] = $head_title;
$variables['head_title'] = implode(' | ', $head_title);
......
......@@ -321,7 +321,7 @@ function hook_block_view_MODULE_DELTA_alter(&$data, $block) {
* An array of $blocks, keyed by the block ID.
*/
function hook_block_list_alter(&$blocks) {
global $language, $theme_key;
global $language_interface, $theme_key;
// This example shows how to achieve language specific visibility setting for
// blocks.
......@@ -345,7 +345,7 @@ function hook_block_list_alter(&$blocks) {
continue;
}
if (!isset($block_languages[$block->module][$block->delta][$language->language])) {
if (!isset($block_languages[$block->module][$block->delta][$language_interface->language])) {
// This block should not be displayed with the active language, remove
// from the list.
unset($blocks[$key]);
......
......@@ -1228,17 +1228,17 @@ function book_toc($bid, $depth_limit, $exclude = array()) {
* @see book-export-html.tpl.php
*/
function template_preprocess_book_export_html(&$variables) {
global $base_url, $language;
global $base_url, $language_interface;
$variables['title'] = check_plain($variables['title']);
$variables['base_url'] = $base_url;
$variables['language'] = $language;
$variables['language_rtl'] = ($language->direction == LANGUAGE_RTL);
$variables['language'] = $language_interface;
$variables['language_rtl'] = ($language_interface->direction == LANGUAGE_RTL);
$variables['head'] = drupal_get_html_head();
// HTML element attributes.
$variables['html_attributes_array']['lang'] = $language->langcode;
$variables['html_attributes_array']['dir'] = $language->direction ? 'rtl' : 'ltr';
$variables['html_attributes_array']['lang'] = $language_interface->langcode;
$variables['html_attributes_array']['dir'] = $language_interface->direction ? 'rtl' : 'ltr';
}
/**
......
......@@ -1860,10 +1860,10 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
* Creates a comment, then tests the tokens generated from it.
*/
function testCommentTokenReplacement() {
global $language;
global $language_interface;
$url_options = array(
'absolute' => TRUE,
'language' => $language,
'language' => $language_interface,
);
$this->drupalLogin($this->admin_user);
......@@ -1896,8 +1896,8 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
$tests['[comment:body]'] = _text_sanitize($instance, LANGUAGE_NONE, $comment->comment_body[LANGUAGE_NONE][0], 'value');
$tests['[comment:url]'] = url('comment/' . $comment->cid, $url_options + array('fragment' => 'comment-' . $comment->cid));
$tests['[comment:edit-url]'] = url('comment/' . $comment->cid . '/edit', $url_options);
$tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->created, 2, $language->langcode);
$tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->changed, 2, $language->langcode);
$tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->created, 2, $language_interface->langcode);
$tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->changed, 2, $language_interface->langcode);
$tests['[comment:parent:cid]'] = $comment->pid;
$tests['[comment:parent:title]'] = check_plain($parent_comment->subject);
$tests['[comment:node:nid]'] = $comment->nid;
......@@ -1909,7 +1909,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('comment' => $comment), array('language' => $language));
$output = token_replace($input, array('comment' => $comment), array('language' => $language_interface));
$this->assertEqual($output, $expected, t('Sanitized comment token %token replaced.', array('%token' => $input)));
}
......@@ -1925,7 +1925,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
$tests['[comment:author:name]'] = $this->admin_user->name;
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('comment' => $comment), array('language' => $language, 'sanitize' => FALSE));
$output = token_replace($input, array('comment' => $comment), array('language' => $language_interface, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, t('Unsanitized comment token %token replaced.', array('%token' => $input)));
}
......@@ -1938,7 +1938,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
$tests['[node:comment-count-new]'] = 2;
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('node' => $node), array('language' => $language));
$output = token_replace($input, array('node' => $node), array('language' => $language_interface));
$this->assertEqual($output, $expected, t('Node comment token %token replaced.', array('%token' => $input)));
}
}
......
......@@ -134,7 +134,7 @@ function contact_site_form_validate($form, &$form_state) {
* @see contact_site_form_validate()
*/
function contact_site_form_submit($form, &$form_state) {
global $user, $language;
global $user, $language_interface;
$values = $form_state['values'];
$values['sender'] = $user;
......@@ -156,12 +156,12 @@ function contact_site_form_submit($form, &$form_state) {
// If the user requests it, send a copy using the current language.
if ($values['copy']) {
drupal_mail('contact', 'page_copy', $from, $language, $values, $from);
drupal_mail('contact', 'page_copy', $from, $language_interface, $values, $from);
}
// Send an auto-reply if necessary using the current language.
if ($values['category']['reply']) {
drupal_mail('contact', 'page_autoreply', $from, $language, $values, $to);
drupal_mail('contact', 'page_autoreply', $from, $language_interface, $values, $to);
}
flood_register_event('contact', variable_get('contact_threshold_window', 3600));
......@@ -270,7 +270,7 @@ function contact_personal_form_validate($form, &$form_state) {
* @see contact_personal_form_validate()
*/
function contact_personal_form_submit($form, &$form_state) {
global $user, $language;
global $user, $language_interface;
$values = $form_state['values'];
$values['sender'] = $user;
......@@ -291,7 +291,7 @@ function contact_personal_form_submit($form, &$form_state) {
// Send a copy if requested, using current page language.
if ($values['copy']) {
drupal_mail('contact', 'user_copy', $from, $language, $values, $from);
drupal_mail('contact', 'user_copy', $from, $language_interface, $values, $from);
}
flood_register_event('contact', variable_get('contact_threshold_window', 3600));
......
......@@ -43,7 +43,7 @@ function entity_modules_disabled() {
* @see hook_entity_info_alter()
*/
function entity_get_info($entity_type = NULL) {
global $language;
global $language_interface;
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
......@@ -54,7 +54,7 @@ function entity_get_info($entity_type = NULL) {
// hook_entity_info() includes translated strings, so each language is cached
// separately.
$langcode = $language->langcode;
$langcode = $language_interface->langcode;
if (empty($entity_info)) {
if ($cache = cache()->get("entity_info:$langcode")) {
......
......@@ -67,7 +67,7 @@ function field_info_cache_clear() {
* @see _field_info_collate_types_reset()
*/
function _field_info_collate_types() {
global $language;
global $language_interface;
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
......@@ -79,7 +79,7 @@ function _field_info_collate_types() {
// The _info() hooks invoked below include translated strings, so each
// language is cached separately.
$langcode = $language->langcode;
$langcode = $language_interface->langcode;
if (!isset($info)) {
if ($cached = cache('field')->get("field_info_types:$langcode")) {
......
......@@ -1051,10 +1051,10 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
* Creates a file, then tests the tokens generated from it.
*/
function testFileTokenReplacement() {
global $language;
global $language_interface;
$url_options = array(
'absolute' => TRUE,
'language' => $language,
'language' => $language_interface,
);
// Create file field.
......@@ -1084,8 +1084,8 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
$tests['[file:mime]'] = check_plain($file->filemime);
$tests['[file:size]'] = format_size($file->filesize);
$tests['[file:url]'] = check_plain(file_create_url($file->uri));
$tests['[file:timestamp]'] = format_date($file->timestamp, 'medium', '', NULL, $language->langcode);
$tests['[file:timestamp:short]'] = format_date($file->timestamp, 'short', '', NULL, $language->langcode);
$tests['[file:timestamp]'] = format_date($file->timestamp, 'medium', '', NULL, $language_interface->langcode);
$tests['[file:timestamp:short]'] = format_date($file->timestamp, 'short', '', NULL, $language_interface->langcode);
$tests['[file:owner]'] = check_plain(user_format_name($this->admin_user));
$tests['[file:owner:uid]'] = $file->uid;
......@@ -1093,7 +1093,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('file' => $file), array('language' => $language));
$output = token_replace($input, array('file' => $file), array('language' => $language_interface));
$this->assertEqual($output, $expected, t('Sanitized file token %token replaced.', array('%token' => $input)));
}
......@@ -1104,7 +1104,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
$tests['[file:size]'] = format_size($file->filesize);
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('file' => $file), array('language' => $language, 'sanitize' => FALSE));
$output = token_replace($input, array('file' => $file), array('language' => $language_interface, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, t('Unsanitized file token %token replaced.', array('%token' => $input)));
}
}
......
......@@ -390,12 +390,12 @@ function filter_modules_disabled($modules) {
* @see filter_formats_reset()
*/
function filter_formats($account = NULL) {
global $language;
global $language_interface;
$formats = &drupal_static(__FUNCTION__, array());
// All available formats are cached for performance.
if (!isset($formats['all'])) {
if ($cache = cache()->get("filter_formats:{$language->langcode}")) {
if ($cache = cache()->get("filter_formats:{$language_interface->langcode}")) {
$formats['all'] = $cache->data;
}
else {
......@@ -407,7 +407,7 @@ function filter_formats($account = NULL) {
->execute()
->fetchAllAssoc('format');
cache()->set("filter_formats:{$language->langcode}", $formats['all']);
cache()->set("filter_formats:{$language_interface->langcode}", $formats['all']);
}
}
......
......@@ -971,11 +971,11 @@ function image_default_style_revert($style) {
* @see image_effect_definition_load()
*/
function image_effect_definitions() {
global $language;
global $language_interface;
// hook_image_effect_info() includes translated strings, so each language is
// cached separately.
$langcode = $language->langcode;
$langcode = $language_interface->langcode;
$effects = &drupal_static(__FUNCTION__);
......
......@@ -192,10 +192,10 @@ function language_delete($langcode) {
* and checks to see if a related right to left CSS file should be included.
*/
function language_css_alter(&$css) {
global $language;
global $language_interface;
// If the current language is RTL, add the CSS file with the RTL overrides.
if ($language->direction == LANGUAGE_RTL) {
if ($language_interface->direction == LANGUAGE_RTL) {
foreach ($css as $data => $item) {
// Only provide RTL overrides for files.
if ($item['type'] == 'file') {
......
......@@ -24,9 +24,9 @@
* did not happen yet and thus they cannot rely on translated variables.
*/
function hook_language_init() {
global $language, $conf;
global $language_interface, $conf;
switch ($language->langcode) {
switch ($language_interface->langcode) {
case 'it':
$conf['site_name'] = 'Il mio sito Drupal';
break;
......@@ -52,10 +52,10 @@ function hook_language_init() {
* The current path.
*/
function hook_language_switch_links_alter(array &$links, $type, $path) {
global $language;
global $language_interface;
if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language->langcode])) {
foreach ($links[$language->langcode] as $link) {
if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language_interface->langcode])) {
foreach ($links[$language_interface->langcode] as $link) {
$link['attributes']['class'][] = 'active-language';
}
}
......
......@@ -231,6 +231,49 @@ function locale_update_8000() {
db_drop_field('locales_source', 'textgroup');
}
/**
* Language type 'language' renamed to 'language_interface'.
*/
function locale_update_8001() {
// Only change language_types if we had this setting saved. Keep order
// of types because that is significant for value dependency.
$types = variable_get('language_types', NULL);
if (!empty($types) && isset($types['language'])) {
$new_types = array();
foreach ($types as $key => $type) {
$new_types[$key == 'language' ? 'language_interface' : $key] = $type;
}
variable_set('language_types', $new_types);
}
// Rename language_negotiation_language setting if exists.
$setting = variable_get('language_negotiation_language', NULL);
if ($setting !== NULL) {
variable_set('language_negotiation_language_interface', $setting);
variable_del('language_negotiation_language');
}
// Rename locale_language_providers_weight_language setting if exists.
$weight = variable_get('locale_language_providers_weight_language', NULL);
if ($weight !== NULL) {
variable_set('locale_language_providers_weight_language_interface', $weight);
variable_del('locale_language_providers_weight_language');
}
// Update block data in all core block related tables. Contributed modules
// storing data for blocks will need to update for themselves.
$block_tables = array('block', 'block_node_type', 'block_role');
foreach ($block_tables as $table) {
db_update($table)
->fields(array(
'delta' => 'language_interface',
))
->condition('delta', 'language')
->condition('module', 'locale')
->execute();
}
}
/**
* @} End of "addtogroup updates-7.x-to-8.x"
* The next series of updates should start at 9000.
......
......@@ -181,7 +181,7 @@ function locale_menu() {
* Initialize date formats according to the user's current locale.
*/
function locale_init() {
global $conf, $language;
global $conf, $language_interface;
include_once DRUPAL_ROOT . '/core/includes/locale.inc';
// For each date type (e.g. long, short), get the localized date format
......@@ -190,7 +190,7 @@ function locale_init() {
// settings page, where we want to display the site default and not the
// localized version.
if (strpos($_GET['q'], 'admin/config/regional/date-time/formats') !== 0) {
$languages = array($language->langcode);
$languages = array($language_interface->langcode);
// Setup appropriate date formats for this locale.
$formats = locale_get_localized_date_format($languages);
......@@ -218,12 +218,12 @@ function locale_permission() {
* @see locale_form_alter()
*/
function locale_language_selector_form($user) {
global $language;
global $language_interface;
// Get list of enabled languages only.
$languages = language_list(TRUE);
// If the user is being created, we set the user language to the page language.
$user_preferred_language = $user->uid ? user_preferred_language($user) : $language;
$user_preferred_language = $user->uid ? user_preferred_language($user) : $language_interface;
$names = array();
foreach ($languages as $langcode => $item) {
......@@ -592,7 +592,7 @@ function locale_language_delete($language) {
* Language code to use for the lookup.
*/
function locale($string = NULL, $context = NULL, $langcode = NULL) {
global $language;
global $language_interface;
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
......@@ -607,11 +607,12 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) {
return $locale_t;
}
$langcode = isset($langcode) ? $langcode : $language->langcode;
$langcode = isset($langcode) ? $langcode : $language_interface->langcode;
// Store database cached translations in a static variable. Only build the
// cache after $language has been set to avoid an unnecessary cache rebuild.
if (!isset($locale_t[$langcode]) && isset($language)) {
// cache after $language_interface has been set to avoid an unnecessary cache
// rebuild.
if (!isset($locale_t[$langcode]) && isset($language_interface)) {
$locale_t[$langcode] = array();
// Disabling the usage of string caching allows a module to watch for
// the exact list of strings used on a page. From a performance
......@@ -702,7 +703,7 @@ function locale_reset() {
* plural formula.
*/
function locale_get_plural($count, $langcode = NULL) {
global $language;
global $language_interface;
// Used to locally cache the plural formulas for all languages.
$plural_formulas = &drupal_static(__FUNCTION__, array());
......@@ -710,7 +711,7 @@ function locale_get_plural($count, $langcode = NULL) {
// individually for each language.
$plural_indexes = &drupal_static(__FUNCTION__ . ':plurals', array());
$langcode = $langcode ? $langcode : $language->langcode;
$langcode = $langcode ? $langcode : $language_interface->langcode;
if (!isset($plural_indexes[$langcode][$count])) {
// Retrieve and statically cache the plural formulas for all languages.
......@@ -788,7 +789,7 @@ function locale_system_update($components) {
* file if necessary, and adds it to the page.
*/
function locale_js_alter(&$javascript) {
global $language;
global $language_interface;
$dir = 'public://' . variable_get('locale_js_directory', 'languages');
$parsed = variable_get('javascript_parsed', array());
......@@ -820,11 +821,11 @@ function locale_js_alter(&$javascript) {
}
// If necessary, rebuild the translation file for the current language.
if (!empty($parsed['refresh:' . $language->langcode])) {
if (!empty($parsed['refresh:' . $language_interface->langcode])) {
// Don't clear the refresh flag on failure, so that another try will
// be performed later.
if (_locale_rebuild_js()) {
unset($parsed['refresh:' . $language->langcode]);
unset($parsed['refresh:' . $language_interface->langcode]);
}
// Store any changes after refresh was attempted.
variable_set('javascript_parsed', $parsed);
......@@ -837,9 +838,9 @@ function locale_js_alter(&$javascript) {
// Add the translation JavaScript file to the page.
$locale_javascripts = variable_get('locale_translation_javascript', array());
if ($files && !empty($locale_javascripts[$language->langcode])) {
if ($files && !empty($locale_javascripts[$language_interface->langcode])) {
// Add the translation JavaScript file to the page.
$file = $dir . '/' . $language->langcode . '_' . $locale_javascripts[$language->langcode] . '.js';
$file = $dir . '/' . $language_interface->langcode . '_' . $locale_javascripts[$language_interface->langcode] . '.js';
$javascript[$file] = drupal_js_defaults($file);
}
}
......@@ -850,14 +851,14 @@ function locale_js_alter(&$javascript) {
* Provides the language support for the jQuery UI Date Picker.
*/
function locale_library_info_alter(&$libraries, $module) {
global $language;
global $language_interface;
if ($module == 'system' && isset($libraries['system']['ui.datepicker'])) {
$datepicker = drupal_get_path('module', 'locale') . '/locale.datepicker.js';
$libraries['system']['ui.datepicker']['js'][$datepicker] = array('group' => JS_THEME);
$libraries['system']['ui.datepicker']['js'][] = array(
'data' => array(
'jqueryuidatepicker' => array(
'rtl' => $language->direction == LANGUAGE_RTL,
'rtl' => $language_interface->direction == LANGUAGE_RTL,
'firstDay' => variable_get('date_first_day', 0),
),
),
......@@ -1085,15 +1086,15 @@ function locale_form_system_file_system_settings_alter(&$form, $form_state) {
*/
function locale_preprocess_node(&$variables) {
if ($variables['language'] != LANGUAGE_NONE) {
global $language;
global $language_interface;
$node_language = language_load($variables['language']);
if ($node_language->langcode != $language->langcode) {
if ($node_language->langcode != $language_interface->langcode) {
// If the node language was different from the page language, we should
// add markup to identify the language. Otherwise the page language is
// inherited.
$variables['attributes_array']['lang'] = $variables['language'];
if ($node_language->direction != $language->direction) {
if ($node_language->direction != $language_interface->direction) {
// If text direction is different form the page's text direction, add
// direction information as well.
$dir = array('ltr', 'rtl');
......
......@@ -1269,7 +1269,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
// Check the UI language.
drupal_language_initialize();
$this->assertEqual($GLOBALS['language']->langcode, $this->langcode, t('Current language: %lang', array('%lang' => $GLOBALS['language']->langcode)));
$this->assertEqual($GLOBALS['language_interface']->langcode, $this->langcode, t('Current language: %lang', array('%lang' => $GLOBALS['language_interface']->langcode)));
// Enable multilingual workflow option for articles.
variable_set('node_type_language_article', 1);
......@@ -1314,7 +1314,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
// Check the init language logic.
drupal_language_initialize();
$this->assertEqual($GLOBALS['language']->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => $GLOBALS['language']->langcode)));
$this->assertEqual($GLOBALS['language_interface']->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => $GLOBALS['language_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'))));
......@@ -1414,7 +1414,7 @@ class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase {
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
$edit = array('language[enabled][locale-url]' => '1');
$edit = array('language_interface[enabled][locale-url]' => '1');
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
// Assert that the language switching block is displayed on the frontpage.
......@@ -1422,7 +1422,7 @@ class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase {
$this->assertText(t('Languages'), t('Language switcher block found.'));
// Assert that only the current language is marked as active.
list($language_switcher) = $this->xpath('//div[@id=:id]/div[@class="content"]', array(':id' => 'block-locale-' . $language_type));
list($language_switcher) = $this->xpath('//div[@id=:id]/div[@class="content"]', array(':id' => 'block-locale-' . str_replace('_', '-', $language_type)));
$links = array(
'active' => array(),
'inactive' => array(),
......@@ -1694,7 +1694,7 @@ class LocaleUserCreationTest extends DrupalWebTestCase {
// Set language negotiation.
$edit = array(
'language[enabled][locale-url]' => TRUE,
'language_interface[enabled][locale-url]' => TRUE,
);
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
$this->assertText(t('Language negotiation configuration saved.'), t('Set language negotiation.'));
......@@ -2348,16 +2348,16 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
// Enable browser and URL language detection.
$edit = array(
'language[enabled][locale-browser]' => TRUE,
'language[enabled][locale-url]' => TRUE,
'language[weight][locale-browser]' => -8,
'language[weight][locale-url]' => -10,
'language_interface[enabled][locale-browser]' => TRUE,
'language_interface[enabled][locale-url]' => TRUE,
'language_interface[weight][locale-browser]' => -8,
'language_interface[weight][locale-url]' => -10,
);
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
$this->drupalGet('admin/config/regional/language/detection');
// Enable the language switcher block.
$edit = array('blocks[locale_language][region]' => 'sidebar_first');
$edit = array('blocks[locale_language_interface][region]' => 'sidebar_first');
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
// Access the front page without specifying any valid URL language prefix
......@@ -2369,7 +2369,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
// Check that the language switcher active link matches the given browser
// language.
$args = array(':url' => base_path() . (!empty($GLOBALS['conf']['clean_url']) ? $langcode_browser_fallback : "?q=$langcode_browser_fallback"));
$fields = $this->xpath('//div[@id="block-locale-language"]//a[@class="language-link active" and @href=:url]', $args);
$fields = $this->xpath('//div[@id="block-locale-language-interface"]//a[@class="language-link active" and @href=:url]', $args);
$this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->name, t('The browser language is the URL active language'));
// Check that URLs are rewritten using the given browser language.
......@@ -2391,8 +2391,8 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {