Commit 1878eb15 authored by catch's avatar catch

Issue #1357918 by Gábor Hojtsy: Change language schema to refer to langcode.

parent a1b360ec
......@@ -1520,7 +1520,7 @@ function t($string, array $args = array(), array $options = array()) {
// Merge in default.
if (empty($options['langcode'])) {
$options['langcode'] = isset($language->language) ? $language->language : LANGUAGE_SYSTEM;
$options['langcode'] = isset($language->langcode) ? $language->langcode : LANGUAGE_SYSTEM;
}
if (empty($options['context'])) {
$options['context'] = '';
......@@ -2677,33 +2677,33 @@ function language_types() {
* - For all other values of $field, the array is only one level deep, and
* the array's values are language objects.
*/
function language_list($field = 'language') {
function language_list($field = 'langcode') {
$languages = &drupal_static(__FUNCTION__);
// Init language list
if (!isset($languages)) {
$default = language_default();
if (language_multilingual() || module_exists('language')) {
$languages['language'] = db_query('SELECT * FROM {language} ORDER BY weight ASC, name ASC')->fetchAllAssoc('language');
$languages['langcode'] = db_query('SELECT * FROM {language} ORDER BY weight ASC, name ASC')->fetchAllAssoc('langcode');
}
else {
// No locale module, so use the default language only.
$languages['language'][$default->language] = $default;
$languages['langcode'][$default->langcode] = $default;
}
// Initialize default property so callers have an easy reference and
// can save the same object without data loss.
foreach ($languages['language'] as $langcode => $language) {
$languages['language'][$langcode]->default = ($langcode == $default->language);
foreach ($languages['langcode'] as $langcode => $language) {
$languages['langcode'][$langcode]->default = ($langcode == $default->langcode);
}
}
// Return the array indexed by the right field
if (!isset($languages[$field])) {
$languages[$field] = array();
foreach ($languages['language'] as $lang) {
foreach ($languages['langcode'] as $lang) {
// Some values should be collected into an array
if (in_array($field, array('enabled', 'weight'))) {
$languages[$field][$lang->$field][$lang->language] = $lang;
$languages[$field][$lang->$field][$lang->langcode] = $lang;
}
else {
$languages[$field][$lang->$field] = $lang;
......@@ -2723,7 +2723,7 @@ function language_default() {
$default = variable_get(
'language_default',
(object) array(
'language' => 'en',
'langcode' => 'en',
'name' => 'English',
'direction' => 0,
'enabled' => 1,
......@@ -3174,7 +3174,7 @@ function registry_update() {
*
* Example:
* @code
* function language_list($field = 'language') {
* function language_list($field = 'langcode') {
* $languages = &drupal_static(__FUNCTION__);
* if (!isset($languages)) {
* // If this function is being called for the first time after a reset,
......
......@@ -1597,7 +1597,7 @@ function filter_xss_bad_protocol($string, $decode = TRUE) {
*/
function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) {
global $language_content;
$langcode = $langcode ? $langcode : $language_content->language;
$langcode = $langcode ? $langcode : $language_content->langcode;
$output = "<channel>\n";
$output .= ' <title>' . check_plain($title) . "</title>\n";
......@@ -1891,7 +1891,7 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
// Use the default langcode if none is set.
global $language;
if (empty($langcode)) {
$langcode = isset($language->language) ? $language->language : LANGUAGE_SYSTEM;
$langcode = isset($language->langcode) ? $language->langcode : LANGUAGE_SYSTEM;
}
switch ($type) {
......@@ -2141,7 +2141,7 @@ function url($path = NULL, array $options = array()) {
$path = '';
}
elseif (!empty($path) && !$options['alias']) {
$language = isset($options['language']) && isset($options['language']->language) ? $options['language']->language : '';
$language = isset($options['language']) && isset($options['language']->langcode) ? $options['language']->langcode : '';
$alias = drupal_get_path_alias($original_path, $language);
if ($alias != $original_path) {
$path = $alias;
......@@ -2314,7 +2314,7 @@ function l($text, $path, array $options = array()) {
// Append active class.
if (($path == $_GET['q'] || ($path == '<front>' && drupal_is_front_page())) &&
(empty($options['language']) || $options['language']->language == $language_url->language)) {
(empty($options['language']) || $options['language']->langcode == $language_url->langcode)) {
$options['attributes']['class'][] = 'active';
}
......@@ -2466,7 +2466,7 @@ 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->language);
drupal_add_http_header('Content-Language', $language->langcode);
// Menu status constants are integers; page content is a string or array.
if (is_int($page_callback_result)) {
......@@ -6143,7 +6143,7 @@ function drupal_render_cid_parts($granularity = NULL) {
// part.
if (language_multilingual()) {
foreach (language_types_configurable() as $language_type) {
$cid_parts[] = $GLOBALS[$language_type]->language;
$cid_parts[] = $GLOBALS[$language_type]->langcode;
}
}
......
......@@ -875,7 +875,7 @@ function _locale_import_parse_quoted($string) {
*/
function _locale_export_get_strings($language = NULL) {
if (isset($language)) {
$result = db_query("SELECT s.lid, s.source, s.context, s.location, t.translation, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language ORDER BY t.plid, t.plural", array(':language' => $language->language));
$result = db_query("SELECT s.lid, s.source, s.context, s.location, t.translation, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language ORDER BY t.plid, t.plural", array(':language' => $language->langcode));
}
else {
$result = db_query("SELECT s.lid, s.source, s.context, s.location, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid ORDER BY t.plid, t.plural");
......@@ -934,8 +934,8 @@ function _locale_export_po_generate($language = NULL, $strings = array(), $heade
$header .= "\"MIME-Version: 1.0\\n\"\n";
$header .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
$header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
if (!empty($locale_plurals[$language->language]['formula'])) {
$header .= "\"Plural-Forms: nplurals=" . $locale_plurals[$language->language]['plurals'] . "; plural=" . strtr($locale_plurals[$language->language]['formula'], array('$' => '')) . ";\\n\"\n";
if (!empty($locale_plurals[$language->langcode]['formula'])) {
$header .= "\"Plural-Forms: nplurals=" . $locale_plurals[$language->langcode]['plurals'] . "; plural=" . strtr($locale_plurals[$language->langcode]['formula'], array('$' => '')) . ";\\n\"\n";
}
}
else {
......@@ -973,7 +973,7 @@ function _locale_export_po_generate($language = NULL, $strings = array(), $heade
$output .= 'msgid_plural ' . _locale_export_string($strings[$plural]['source']);
if (isset($language)) {
$translation = $string['translation'];
for ($i = 0; $i < $locale_plurals[$language->language]['plurals']; $i++) {
for ($i = 0; $i < $locale_plurals[$language->langcode]['plurals']; $i++) {
$output .= 'msgstr[' . $i . '] ' . _locale_export_string($translation);
if ($plural) {
$translation = _locale_export_remove_plural($strings[$plural]['translation']);
......@@ -1011,7 +1011,7 @@ function _locale_export_po_generate($language = NULL, $strings = array(), $heade
function _locale_export_po($language = NULL, $output = NULL) {
// Log the export event.
if (isset($language)) {
$filename = $language->language . '.po';
$filename = $language->langcode . '.po';
watchdog('locale', 'Exported %locale translation file: %filename.', array('%locale' => $language->name, '%filename' => $filename));
}
else {
......
......@@ -1272,7 +1272,7 @@ function install_select_language_form($form, &$form_state, $files) {
}
// Build a list of languages simulated for browser detection.
$languages[$file->langcode] = (object) array(
'language' => $file->langcode,
'langcode' => $file->langcode,
);
}
......@@ -1418,7 +1418,7 @@ function install_import_translations(&$install_state) {
// Drupal does not know about this language, so we prefill its values with
// our best guess. The user will be able to edit afterwards.
$language = (object) array(
'language' => $langcode,
'langcode' => $langcode,
'name' => $langcode,
'default' => TRUE,
);
......@@ -1427,7 +1427,7 @@ function install_import_translations(&$install_state) {
else {
// A known predefined language, details will be filled in properly.
$language = (object) array(
'language' => $langcode,
'langcode' => $langcode,
'default' => TRUE,
);
language_save($language);
......
......@@ -405,7 +405,7 @@ function language_initialize($type) {
* The default language code.
*/
function language_from_default() {
return language_default()->language;
return language_default()->langcode;
}
/**
......@@ -432,7 +432,7 @@ function language_url_split_prefix($path, $languages) {
// Search prefix within enabled languages.
$prefixes = locale_language_negotiation_url_prefixes();
foreach ($languages as $language) {
if (isset($prefixes[$language->language]) && $prefixes[$language->language] == $prefix) {
if (isset($prefixes[$language->langcode]) && $prefixes[$language->langcode] == $prefix) {
// Rebuild $path with the language removed.
return array($language, implode('/', $args));
}
......@@ -460,7 +460,7 @@ function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) {
// Use array keys to avoid duplicated entries.
foreach (language_list('weight') as $languages) {
foreach ($languages as $language) {
$fallback_candidates[$language->language] = NULL;
$fallback_candidates[$language->langcode] = NULL;
}
}
......
......@@ -113,7 +113,7 @@
*/
function locale_language_from_interface() {
global $language;
return isset($language->language) ? $language->language : FALSE;
return isset($language->langcode) ? $language->langcode : FALSE;
}
/**
......@@ -193,7 +193,7 @@ function locale_language_from_browser($languages) {
// Find the best match.
if ($qvalue > $max_qvalue) {
$best_match_langcode = $language->language;
$best_match_langcode = $language->langcode;
$max_qvalue = $qvalue;
}
}
......@@ -274,7 +274,7 @@ function locale_language_from_url($languages) {
// path initialization runs after the language bootstrap phase.
list($language, $_GET['q']) = language_url_split_prefix(isset($_GET['q']) ? $_GET['q'] : NULL, $languages);
if ($language !== FALSE) {
$language_url = $language->language;
$language_url = $language->langcode;
}
break;
......@@ -282,13 +282,13 @@ function locale_language_from_url($languages) {
$domains = locale_language_negotiation_url_domains();
foreach ($languages as $language) {
// Skip check if the language doesn't have a domain.
if (!empty($domains[$language->language])) {
if (!empty($domains[$language->langcode])) {
// Only compare the domains not the protocols or ports.
// Remove protocol and add http:// so parse_url works
$host = 'http://' . str_replace(array('http://', 'https://'), '', $domains[$language->language]);
$host = 'http://' . str_replace(array('http://', 'https://'), '', $domains[$language->langcode]);
$host = parse_url($host, PHP_URL_HOST);
if ($_SERVER['HTTP_HOST'] == $host) {
$language_url = $language->language;
$language_url = $language->langcode;
break;
}
}
......@@ -340,11 +340,11 @@ function locale_language_url_fallback($language = NULL, $language_type = LANGUAG
// the default one, otherwise we fall back to an already detected language.
$domains = locale_language_negotiation_url_domains();
$prefixes = locale_language_negotiation_url_prefixes();
if (($prefix && empty($prefixes[$default->language])) || (!$prefix && empty($domains[$default->language]))) {
return $default->language;
if (($prefix && empty($prefixes[$default->langcode])) || (!$prefix && empty($domains[$default->langcode]))) {
return $default->langcode;
}
else {
return $GLOBALS[$language_type]->language;
return $GLOBALS[$language_type]->langcode;
}
}
......@@ -357,7 +357,7 @@ function locale_language_switcher_url($type, $path) {
$links = array();
foreach ($languages[1] as $language) {
$links[$language->language] = array(
$links[$language->langcode] = array(
'href' => $path,
'title' => $language->name,
'language' => $language,
......@@ -375,7 +375,7 @@ function locale_language_switcher_session($type, $path) {
drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
$param = variable_get('locale_language_negotiation_session_param', 'language');
$language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $GLOBALS[$type]->language;
$language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $GLOBALS[$type]->langcode;
$languages = language_list('enabled');
$links = array();
......@@ -384,7 +384,7 @@ function locale_language_switcher_session($type, $path) {
unset($query['q']);
foreach ($languages[1] as $language) {
$langcode = $language->language;
$langcode = $language->langcode;
$links[$langcode] = array(
'href' => $path,
'title' => $language->name,
......@@ -423,7 +423,7 @@ function locale_language_url_rewrite_url(&$path, &$options) {
$options['language'] = $language_url;
}
// We allow only enabled languages here.
elseif (!isset($languages[$options['language']->language])) {
elseif (!isset($languages[$options['language']->langcode])) {
unset($options['language']);
return;
}
......@@ -432,17 +432,17 @@ function locale_language_url_rewrite_url(&$path, &$options) {
switch (variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX)) {
case LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN:
$domains = locale_language_negotiation_url_domains();
if (!empty($domains[$options['language']->language])) {
if (!empty($domains[$options['language']->langcode])) {
// Ask for an absolute URL with our modified base_url.
$options['absolute'] = TRUE;
$options['base_url'] = $domains[$options['language']->language];
$options['base_url'] = $domains[$options['language']->langcode];
}
break;
case LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX:
$prefixes = locale_language_negotiation_url_prefixes();
if (!empty($prefixes[$options['language']->language])) {
$options['prefix'] = $prefixes[$options['language']->language] . '/';
if (!empty($prefixes[$options['language']->langcode])) {
$options['prefix'] = $prefixes[$options['language']->langcode] . '/';
}
break;
}
......@@ -709,7 +709,7 @@ function _locale_rebuild_js($langcode = NULL) {
// Construct the array for JavaScript translations.
// Only add strings with a translation to the translations array.
$result = db_query("SELECT s.lid, s.source, s.context, t.translation FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.location LIKE '%.js%'", array(':language' => $language->language));
$result = db_query("SELECT s.lid, s.source, s.context, t.translation FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.location LIKE '%.js%'", array(':language' => $language->langcode));
$translations = array();
foreach ($result as $data) {
......@@ -724,8 +724,8 @@ function _locale_rebuild_js($langcode = NULL) {
$data = "Drupal.locale = { ";
$locale_plurals = variable_get('locale_translation_plurals', array());
if (!empty($locale_plurals[$language->language])) {
$data .= "'pluralFormula': function (\$n) { return Number({$locale_plurals[$language->language]['formula']}); }, ";
if (!empty($locale_plurals[$language->langcode])) {
$data .= "'pluralFormula': function (\$n) { return Number({$locale_plurals[$language->langcode]['formula']}); }, ";
}
$data .= "'strings': " . drupal_json_encode($translations) . " };";
......@@ -738,23 +738,23 @@ function _locale_rebuild_js($langcode = NULL) {
// Delete old file, if we have no translations anymore, or a different file to be saved.
$locale_javascripts = variable_get('locale_translation_javascript', array());
$changed_hash = !isset($locale_javascripts[$language->language]) || ($locale_javascripts[$language->language] != $data_hash);
if (!empty($locale_javascripts[$language->language]) && (!$data || $changed_hash)) {
file_unmanaged_delete($dir . '/' . $language->language . '_' . $locale_javascripts[$language->language] . '.js');
$locale_javascripts[$language->language] = '';
$changed_hash = !isset($locale_javascripts[$language->langcode]) || ($locale_javascripts[$language->langcode] != $data_hash);
if (!empty($locale_javascripts[$language->langcode]) && (!$data || $changed_hash)) {
file_unmanaged_delete($dir . '/' . $language->langcode . '_' . $locale_javascripts[$language->langcode] . '.js');
$locale_javascripts[$language->langcode] = '';
$status = 'deleted';
}
// Only create a new file if the content has changed or the original file got
// lost.
$dest = $dir . '/' . $language->language . '_' . $data_hash . '.js';
$dest = $dir . '/' . $language->langcode . '_' . $data_hash . '.js';
if ($data && ($changed_hash || !file_exists($dest))) {
// Ensure that the directory exists and is writable, if possible.
file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
// Save the file.
if (file_unmanaged_save_data($data, $dest)) {
$locale_javascripts[$language->language] = $data_hash;
$locale_javascripts[$language->langcode] = $data_hash;
// If we deleted a previous version of the file and we replace it with a
// new one we have an update.
if ($status == 'deleted') {
......@@ -772,7 +772,7 @@ function _locale_rebuild_js($langcode = NULL) {
}
}
else {
$locale_javascripts[$language->language] = '';
$locale_javascripts[$language->langcode] = '';
$status = 'error';
}
}
......@@ -790,7 +790,7 @@ function _locale_rebuild_js($langcode = NULL) {
watchdog('locale', 'Updated JavaScript translation file for the language %language.', array('%language' => $language->name));
return TRUE;
case 'rebuilt':
watchdog('locale', 'JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->language]), WATCHDOG_WARNING);
watchdog('locale', 'JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->langcode]), WATCHDOG_WARNING);
// Proceed to the 'created' case as the JavaScript translation file has
// been created again.
case 'created':
......
......@@ -63,7 +63,7 @@
* $message['send'] = FALSE;
* break;
* }
* $langcode = $message['language']->language;
* $langcode = $message['language']->langcode;
* $message['subject'] = t('Notification from !site', $variables, array('langcode' => $langcode));
* $message['body'][] = t("Dear !username\n\nThere is new content available on the site.", $variables, array('langcode' => $langcode));
* break;
......
......@@ -1100,7 +1100,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']->language . ':' . (int) $max_depth;
$cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $GLOBALS['language']->langcode . ':' . (int) $max_depth;
if (!isset($tree[$cid])) {
// If the static variable doesn't have the data, check {cache_menu}.
......@@ -1214,7 +1214,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']->language . ':' . (int) $item['access'] . ':' . (int) $max_depth;
$cid = 'links:' . $menu_name . ':page:' . $item['href'] . ':' . $GLOBALS['language']->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
......@@ -1366,7 +1366,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']->language . ':' . hash('sha256', serialize($parameters));
$tree_cid = 'links:' . $menu_name . ':tree-data:' . $GLOBALS['language']->langcode . ':' . hash('sha256', serialize($parameters));
// If we do not have this tree in the static cache, check {cache_menu}.
if (!isset($trees[$tree_cid])) {
......
......@@ -74,7 +74,7 @@ function drupal_lookup_path($action, $path = '', $path_language = 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.
$path_language = $path_language ? $path_language : $language_url->language;
$path_language = $path_language ? $path_language : $language_url->langcode;
if ($action == 'wipe') {
$cache = array();
......
......@@ -1624,7 +1624,7 @@ function theme_links($variables) {
// Handle links.
if (isset($link['href'])) {
$is_current_path = ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()));
$is_current_language = (empty($link['language']) || $link['language']->language == $language_url->language);
$is_current_language = (empty($link['language']) || $link['language']->langcode == $language_url->langcode);
if ($is_current_path && $is_current_language) {
$class[] = 'active';
}
......@@ -2353,7 +2353,7 @@ function template_preprocess_html(&$variables) {
$variables['body_attributes_array'] = array();
// HTML element attributes.
$variables['html_attributes_array']['lang'] = $GLOBALS['language']->language;
$variables['html_attributes_array']['lang'] = $GLOBALS['language']->langcode;
$variables['html_attributes_array']['dir'] = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
// Add favicon.
......
......@@ -141,6 +141,17 @@ function update_prepare_d8_language() {
db_drop_field('languages', 'domain');
db_drop_field('languages', 'native');
// Rename language column to langcode and set it again as the primary key.
db_drop_primary_key('languages');
$langcode_spec = array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => "Language code, e.g. 'de' or 'en-US'.",
);
db_change_field('languages', 'language', 'langcode', $langcode_spec, array('primary key' => array('langcode')));
// Rename the languages table to language.
db_rename_table('languages', 'language');
......
......@@ -7,7 +7,7 @@
* Available variables:
* - $title: Top level node title.
* - $head: Header tags.
* - $language: Language code. e.g. "en" for english.
* - $language: Language object.
* - $language_rtl: TRUE or FALSE depending on right to left language scripts.
* - $base_url: URL to home page.
* - $contents: Nodes within the current outline rendered through
......@@ -19,7 +19,7 @@
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language; ?>" xml:lang="<?php print $language->language; ?>">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->langcode; ?>" xml:lang="<?php print $language->langcode; ?>">
<head>
<title><?php print $title; ?></title>
<?php print $head; ?>
......
......@@ -168,7 +168,7 @@ function comment_schema() {
'description' => "The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on.",
),
'language' => array(
'description' => 'The {language}.language of this comment.',
'description' => 'The {language}.langcode of this comment.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
......
......@@ -945,7 +945,7 @@ function comment_prepare_thread(&$comments) {
*/
function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
$langcode = $GLOBALS['language_content']->langcode;
}
// Populate $comment->content with a render() array.
......@@ -1012,7 +1012,7 @@ function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) {
*/
function comment_build_content($comment, $node, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
$langcode = $GLOBALS['language_content']->langcode;
}
// Remove previously built content, if exists.
......
......@@ -1779,8 +1779,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->language);
$tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->changed, 2, $language->language);
$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:parent:cid]'] = $comment->pid;
$tests['[comment:parent:title]'] = check_plain($parent_comment->subject);
$tests['[comment:node:nid]'] = $comment->nid;
......
......@@ -106,7 +106,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
$url_options = array('absolute' => TRUE);
if (isset($options['language'])) {
$url_options['language'] = $options['language'];
$language_code = $options['language']->language;
$language_code = $options['language']->langcode;
}
else {
$language_code = NULL;
......
......@@ -183,13 +183,13 @@ function contact_mail($key, &$message, $params) {
switch ($key) {
case 'page_mail':
case 'page_copy':
$message['subject'] .= t('[!category] !subject', $variables, array('langcode' => $language->language));
$message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, array('langcode' => $language->language));
$message['subject'] .= t('[!category] !subject', $variables, array('langcode' => $language->langcode));
$message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, array('langcode' => $language->langcode));
$message['body'][] = $params['message'];
break;
case 'page_autoreply':
$message['subject'] .= t('[!category] !subject', $variables, array('langcode' => $language->language));
$message['subject'] .= t('[!category] !subject', $variables, array('langcode' => $language->langcode));
$message['body'][] = $params['category']['reply'];
break;
......@@ -199,11 +199,11 @@ function contact_mail($key, &$message, $params) {
'!recipient-name' => format_username($params['recipient']),
'!recipient-edit-url' => url('user/' . $params['recipient']->uid . '/edit', array('absolute' => TRUE, 'language' => $language)),
);
$message['subject'] .= t('[!site-name] !subject', $variables, array('langcode' => $language->language));
$message['body'][] = t('Hello !recipient-name,', $variables, array('langcode' => $language->language));
$message['body'][] = t("!sender-name (!sender-url) has sent you a message via your contact form (!form-url) at !site-name.", $variables, array('langcode' => $language->language));
$message['body'][] = t("If you don't want to receive such e-mails, you can change your settings at !recipient-edit-url.", $variables, array('langcode' => $language->language));
$message['body'][] = t('Message:', array(), array('langcode' => $language->language));
$message['subject'] .= t('[!site-name] !subject', $variables, array('langcode' => $language->langcode));
$message['body'][] = t('Hello !recipient-name,', $variables, array('langcode' => $language->langcode));
$message['body'][] = t("!sender-name (!sender-url) has sent you a message via your contact form (!form-url) at !site-name.", $variables, array('langcode' => $language->langcode));
$message['body'][] = t("If you don't want to receive such e-mails, you can change your settings at !recipient-edit-url.", $variables, array('langcode' => $language->langcode));
$message['body'][] = t('Message:', array(), array('langcode' => $language->langcode));
$message['body'][] = $params['message'];
break;
}
......
......@@ -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->language;
$langcode = $language->langcode;
if (empty($entity_info)) {
if ($cache = cache()->get("entity_info:$langcode")) {
......
......@@ -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->language;
$langcode = $language->langcode;
if (!isset($info)) {
if ($cached = cache('field')->get("field_info_types:$langcode")) {
......
......@@ -245,7 +245,7 @@ function field_valid_language($langcode, $default = TRUE) {
return $langcode;
}
global $language_content;
return $default ? language_default()->language : $language_content->language;
return $default ? language_default()->langcode : $language_content->langcode;
}
/**
......
......@@ -2646,7 +2646,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
require_once DRUPAL_ROOT . '/core/includes/locale.inc';
for ($i = 0; $i < 3; ++$i) {
$language = (object) array(
'language' => 'l' . $i,
'langcode' => 'l' . $i,
'name' => $this->randomString(),
);
language_save($language);
......
......@@ -1081,8 +1081,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->language);
$tests['[file:timestamp:short]'] = format_date($file->timestamp, 'short', '', NULL, $language->language);
$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:owner]'] = check_plain(format_username($this->admin_user));
$tests['[file:owner:uid]'] = $file->uid;
......
......@@ -395,7 +395,7 @@ function filter_formats($account = NULL) {
// All available formats are cached for performance.
if (!isset($formats['all'])) {
if ($cache = cache()->get("filter_formats:{$language->language}")) {
if ($cache = cache()->get("filter_formats:{$language->langcode}")) {
$formats['all'] = $cache->data;
}
else {
......@@ -407,7 +407,7 @@ function filter_formats($account = NULL) {
->execute()
->fetchAllAssoc('format');
cache()->set("filter_formats:{$language->language}", $formats['all']);
cache()->set("filter_formats:{$language->langcode}", $formats['all']);
}
}
......
......@@ -975,7 +975,7 @@ function image_effect_definitions() {
// hook_image_effect_info() includes translated strings, so each language is
// cached separately.
$langcode = $language->language;
$langcode = $language->langcode;
$effects = &drupal_static(__FUNCTION__);
......
......@@ -10,7 +10,7 @@
*/
function language_admin_overview_form($form, &$form_state) {
drupal_static_reset('language_list');
$languages = language_list('language');
$languages = language_list();
$default = language_default();
$form['languages'] = array(
......@@ -37,7 +37,7 @@ function language_admin_overview_form($form, &$form_state) {
'#title' => t('Enable @title', array('@title' => $language->name)),
'#title_display' => 'invisible',
'#default_value' => (int) $language->enabled,
'#disabled' => $langcode == $default->language,
'#disabled' => $langcode == $default->langcode,
);
$form['languages'][$langcode]['default'] = array(
'#type' => 'radio',
......@@ -45,7 +45,7 @@ function language_admin_overview_form($form, &$form_state) {
'#title' => t('Set @title as default', array('@title' => $language->name)),
'#title_display' => 'invisible',