From b75c1e1c8bdc9b0fafaed8b7de8b27dec6fefd66 Mon Sep 17 00:00:00 2001
From: Steven Wittens <steven@10.no-reply.drupal.org>
Date: Thu, 9 Sep 2004 13:36:01 +0000
Subject: [PATCH] Replace hardcoded <html lang="en"> with a locale dependant
 one. This is especially important for asian sites where this has an effect on
 font selection.

---
 includes/common.inc                       | 4 +++-
 modules/node.module                       | 5 ++---
 modules/node/node.module                  | 5 ++---
 themes/bluemarine/xtemplate.xtmpl         | 2 +-
 themes/chameleon/chameleon.theme          | 4 +++-
 themes/engines/xtemplate/xtemplate.engine | 1 +
 themes/pushbutton/xtemplate.xtmpl         | 2 +-
 7 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/includes/common.inc b/includes/common.inc
index b138d79b572b..ce388c2e9993 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -508,7 +508,9 @@ function locale_initialize() {
     $languages = $languages['name'];
   }
   else {
-    $languages = array();
+    // Ensure the locale/language is correctly returned, even without locale.module.
+    // Useful for e.g. XML/HTML 'lang' attributes.
+    $languages = array('en' => 'English');
   }
   if ($user->uid && $languages[$user->language]) {
     return $user->language;
diff --git a/modules/node.module b/modules/node.module
index d750593cb189..e4773d5690ac 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -993,8 +993,7 @@ function node_block($op = 'list', $delta = 0) {
  *   The link should be an absolute URL.
  */
 function node_feed($nodes = 0, $channel = array()) {
-  global $base_url;
-  $languages = (function_exists('locale')) ? locale_supported_languages() : array('name' => array());
+  global $base_url, $locale;
 
   if (!$nodes) {
     $nodes = db_query_range('SELECT nid FROM {node} WHERE promote = 1 AND status = 1 ORDER BY created DESC', 0, 15);
@@ -1012,7 +1011,7 @@ function node_feed($nodes = 0, $channel = array()) {
     'title'       => variable_get('site_name', 'drupal') .' - '. variable_get('site_slogan', ''),
     'link'        => $base_url,
     'description' => variable_get('site_mission', ''),
-    'language'    => (($key = reset(array_keys($languages['name']))) ? $key : 'en')
+    'language'    => $locale
   );
   $channel = array_merge($channel_defaults, $channel);
 
diff --git a/modules/node/node.module b/modules/node/node.module
index d750593cb189..e4773d5690ac 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -993,8 +993,7 @@ function node_block($op = 'list', $delta = 0) {
  *   The link should be an absolute URL.
  */
 function node_feed($nodes = 0, $channel = array()) {
-  global $base_url;
-  $languages = (function_exists('locale')) ? locale_supported_languages() : array('name' => array());
+  global $base_url, $locale;
 
   if (!$nodes) {
     $nodes = db_query_range('SELECT nid FROM {node} WHERE promote = 1 AND status = 1 ORDER BY created DESC', 0, 15);
@@ -1012,7 +1011,7 @@ function node_feed($nodes = 0, $channel = array()) {
     'title'       => variable_get('site_name', 'drupal') .' - '. variable_get('site_slogan', ''),
     'link'        => $base_url,
     'description' => variable_get('site_mission', ''),
-    'language'    => (($key = reset(array_keys($languages['name']))) ? $key : 'en')
+    'language'    => $locale
   );
   $channel = array_merge($channel_defaults, $channel);
 
diff --git a/themes/bluemarine/xtemplate.xtmpl b/themes/bluemarine/xtemplate.xtmpl
index fbeef1e58e7d..c9a41cd884f9 100644
--- a/themes/bluemarine/xtemplate.xtmpl
+++ b/themes/bluemarine/xtemplate.xtmpl
@@ -1,5 +1,5 @@
 <!-- BEGIN: header --><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="{language}" xml:lang="{language}">
 
 <head>
   <title>{head_title}</title>
diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme
index 154cb2e4b990..307d87615beb 100644
--- a/themes/chameleon/chameleon.theme
+++ b/themes/chameleon/chameleon.theme
@@ -24,8 +24,10 @@ function chameleon_page($content, $title = NULL, $breadcrumb = NULL) {
     drupal_set_breadcrumb($breadcrumb);
   }
 
+  $language = $GLOBALS['locale'];
+
   $output  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
-  $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n";
+  $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"$language\" xml:lang=\"$language\">\n";
   $output .= "<head>\n";
   $output .= " <title>". ($title ? $title ." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";
   $output .= drupal_get_html_head();
diff --git a/themes/engines/xtemplate/xtemplate.engine b/themes/engines/xtemplate/xtemplate.engine
index 2b91f70d7994..14bd20a5582f 100644
--- a/themes/engines/xtemplate/xtemplate.engine
+++ b/themes/engines/xtemplate/xtemplate.engine
@@ -120,6 +120,7 @@ function xtemplate_page($content, $title = NULL, $breadcrumb = NULL) {
   global $xtemplate;
 
   $xtemplate->template->assign(array(
+    "language" => $GLOBALS['locale'],
     "head_title" => (drupal_get_title() ? drupal_get_title() ." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")),
     "head" => drupal_get_html_head(),
     "styles" => theme_get_styles(),
diff --git a/themes/pushbutton/xtemplate.xtmpl b/themes/pushbutton/xtemplate.xtmpl
index dbd6bdb9b99a..a18a8118c02e 100644
--- a/themes/pushbutton/xtemplate.xtmpl
+++ b/themes/pushbutton/xtemplate.xtmpl
@@ -1,5 +1,5 @@
 <!-- BEGIN: header --><!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" xml:lang="en" lang="en">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="{language}" xml:lang="{language}">
 <head>
   <title>{head_title}</title>
   {head}
-- 
GitLab