Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
a58940f1
Commit
a58940f1
authored
Feb 22, 2012
by
Dries
Browse files
- Patch
#1222194
by Gábor Hojtsy, plach: rename global to ().
parent
edabf1fc
Changes
40
Hide whitespace changes
Inline
Side-by-side
core/includes/bootstrap.inc
View file @
a58940f1
...
...
@@ -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'
]
=
''
;
...
...
core/includes/common.inc
View file @
a58940f1
...
...
@@ -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
))
{
...
...
core/includes/locale.inc
View file @
a58940f1
...
...
@@ -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 $lang
uag
e
* @param $lang
cod
e
* 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.
...
...
core/includes/menu.inc
View file @
a58940f1
...
...
@@ -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
]))
{
...
...
core/includes/theme.inc
View file @
a58940f1
...
...
@@ -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
);
...
...
core/modules/block/block.api.php
View file @
a58940f1
...
...
@@ -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
]);
...
...
core/modules/book/book.module
View file @
a58940f1
...
...
@@ -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'
;
}
/**
...
...
core/modules/comment/comment.test
View file @
a58940f1
...
...
@@ -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
)));
}
}
...
...
core/modules/contact/contact.pages.inc
View file @
a58940f1
...
...
@@ -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
));
...
...
core/modules/entity/entity.module
View file @
a58940f1
...
...
@@ -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
"
))
{
...
...
core/modules/field/field.info.inc
View file @
a58940f1
...
...
@@ -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
"
))
{
...
...
core/modules/file/tests/file.test
View file @
a58940f1
...
...
@@ -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
)));
}
}
...
...
core/modules/filter/filter.module
View file @
a58940f1
...
...
@@ -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'
]);
}
}
...
...
core/modules/image/image.module
View file @
a58940f1
...
...
@@ -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__
);
...
...
core/modules/language/language.module
View file @
a58940f1
...
...
@@ -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'
)
{
...
...
core/modules/locale/locale.api.php
View file @
a58940f1
...
...
@@ -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'
;
}
}
...
...
core/modules/locale/locale.install
View file @
a58940f1
...
...
@@ -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.
...
...
core/modules/locale/locale.module
View file @
a58940f1
...
...
@@ -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'
<