function locale_preprocess_node

Implements hook_preprocess_HOOK() for node.tpl.php.

File

drupal/core/modules/locale/locale.module, line 727
Enables the translation of the user interface to languages other than English.

Code

function locale_preprocess_node(&$variables) {
  if ($variables['node']->langcode != LANGUAGE_NOT_SPECIFIED) {
    $language_interface = language(LANGUAGE_TYPE_INTERFACE);
    $node_language = language_load($variables['node']->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']['lang'] = $variables['node']->langcode;
      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',
        );
        $variables['attributes']['dir'] = $dir[$node_language->direction];
      }
    }
  }
}