Would it be an option to include the language metatag to support multi language sites? It helps search engines to decide which language is supported. I notice that Google mixes the different languages in the search results.

where language can be replaced by $locale .

Comments

giorgio79’s picture

Was just looking for this exact thing.

Locale is core in Drupal 6 and I just enabled selecting language for content type, but the language does not appear in meta...

1websitedesigner’s picture

Hi,

You'd need the Internationalization module, which is at:

http://drupal.org/project/i18n

This lets you select other languages, easily manage translations, etc.

There's also a bit more explanation of the language metatag (not specific to Drupal) on:

http://www.1websitedesigner.com/language-metatags

avpaderno’s picture

Status: Active » Closed (won't fix)

The module doesn't support meta tags like <meta http-equiv="Content-Language" content="en">; the only meta tags it supports are like <meta name="robots" content="noindex,nofollow">.

avpaderno’s picture

Title: Language metatag based on locale for multiple language sites? » Language meta tag based on currently set locale
Hobbes-2’s picture

subscribe

Jeordy’s picture

Well, i've combined some posts into the following code. Put this in your template.php. This is for Drupal 7, by the way.

//Where the function says: template_page_alter, change template into your template name (for example: bartik_page_alter)
function template_page_alter($page) {
  global $language ;
  $lang_name = $language->language ;
 
  $meta_language = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
    'http-equiv' => 'content-language',
    'content' =>  $lang_name
    )
  );

  $meta_content_language = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
    'http-equiv' => 'language',
    'content' =>  $lang_name
    )
  );
drupal_add_html_head( $meta_language, 'content-language' );
drupal_add_html_head( $meta_content_language, 'language' );
}

When you look at the source code, you will find 2 extra meta fields containing language and content-language.

Hope this helps.

damienmckenna’s picture

@Jeordy: Thanks. The Metatag module might benefit from your code snippet, Nodewords doesn't work on D7.

tommer’s picture

Thanks Jeordy. I needed solution for D6, so here it is:

function mytheme_preprocess_page(&$vars, $hook) {
  global $language ;
  $lang_name = $language->language ;

  $vars['head'] .= '<meta http-equiv="Content-Language" content="'.$lang_name.'">';
}