Implements hook_preprocess_HOOK() for node.tpl.php.
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];
}
}
}
}