diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 103c284..ec99160 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -1175,3 +1175,21 @@ function locale_form_system_file_system_settings_alter(&$form, $form_state) {
     $form['file_default_scheme']['#weight'] = 20;
   }
 }
+
+/**
+ * Implements MODULE_preprocess_HOOK().
+ */
+function locale_preprocess_node(&$variables) {
+  if ($variables['language'] != LANGUAGE_NONE) {
+    global $language;
+
+    $node_language = language_load($variables['language']);
+    if ($node_language->language != $language->language){
+      $variables['attributes_array']['lang'] = $variables['language'];
+      if ($node_language->direction != $language->direction) {
+        $dir = array('ltr', 'rtl');
+        $variables['attributes_array']['dir'] = $dir[$node_language->direction];
+      }
+    }
+  }
+}
diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test
index 3474d78..43acac4 100644
--- a/core/modules/locale/locale.test
+++ b/core/modules/locale/locale.test
@@ -1956,6 +1956,63 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
 
     $this->drupalLogout();
   }
+
+  /**
+   * Test if a dir and lang is correct when the system language is different from the node
+   */
+  function testContentTypeDirLang() {
+    global $base_url;
+
+    // User to add and remove language.
+    $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages'));
+    // User to create a node.
+    $web_user = $this->drupalCreateUser(array('create article content', 'create page content', 'edit any page content'));
+
+    // Login as admin.
+    $this->drupalLogin($admin_user);
+
+    // Install Arabic language.
+    $langcode = 'ar';
+    $edit = array();
+    $edit['predefined_langcode'] = $langcode;
+    $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
+
+    // Set "Basic page" content type to use multilingual support.
+    $this->drupalGet('admin/structure/types/manage/page');
+    $edit = array(
+      'language_content_type' => 1,
+    );
+    $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
+    $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), t('Basic page content type has been updated.'));
+    $this->drupalLogout();
+
+    // Login as web user to add new page.
+    $this->drupalLogin($web_user);
+    $this->drupalGet('node/add/page');
+
+    // Create Arabic "Basic page" content.
+    $node_title = $this->randomName();
+    $node_body =  $this->randomName();
+    $edit = array(
+      'type' => 'page',
+      'title' => $node_title,
+      'body' => array($langcode => array(array('value' => $node_body))),
+      'language' => $langcode,
+    );
+    $node = $this->drupalCreateNode($edit);
+
+    // Check if the node created successfully.
+    $this->drupalGet('node/' . $node->nid);
+    $this->assertText($edit['title'], t('The randomly generated node name is present.'));
+
+    // Check if the lang tag assigned correctly.
+    $this->assertPattern('|lang="ar"|', t('The lang tag has been assigned correctly.'));
+
+    // Check if the dir tag assigned correctly.
+    $this->assertPattern('|dir="rtl"|', t('The dir tag has been assigned correctly.'));
+
+    $this->drupalLogout();
+  }
 }
 
 /**
