diff --git a/ds.module b/ds.module
index 03864c8..0d59058 100644
--- a/ds.module
+++ b/ds.module
@@ -865,61 +865,82 @@ function ds_render_ctools_field($field) {
  * Render a block field.
  */
 function ds_render_block_field($field) {
-  global $theme;
-
-  // The the block definition and invoke the hook.
+  // Invoke the block_view hook of the module.
   list($module, $delta) = explode('|', $field['properties']['block']);
-  $block = db_query("SELECT * FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme", array(':module' => $module, ':delta' => $delta, ':theme' => $theme))->fetchObject();
-
-  // In case there is no definition, the block is either removed or the block
-  // list hasn't been updated yet.
-  if (empty($block)) {
-    return;
+  $block = module_invoke($module, 'block_view', $delta);
+
+  // Get contextual links.
+  $contextual_links = array();
+  $contextual = module_exists('contextual') && user_access('access contextual links');
+  if ($contextual) {
+    if (is_array($block['content']) && isset($block['content']['#contextual_links'])) {
+      $contextual_links = $block['content']['#contextual_links'];
+    }
   }
 
-  // Invoke the block hook.
-  $array = module_invoke($block->module, 'block_view', $block->delta);
-
-  // Allow modules to modify the block before it is viewed, via either
-  // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
-  drupal_alter(array('block_view', "block_view_{$block->module}_{$block->delta}"), $array, $block);
+  // Render the block content.
+  if (isset($block['content']) && is_array($block['content'])) {
+    $block['content'] = drupal_render($block['content']);
+  }
 
-  if (!empty($array)) {
+  // Go through in case we have actual content.
+  if (!empty($block['content'])) {
 
-    // Make sure the subject key is set.
-    if (!isset($array['subject'])) {
-      $array['subject'] = '';
+    // Make sure subject is set.
+    if (!isset($block['subject'])) {
+      $block['subject'] = '';
     }
 
-    // Set the subject on the $block object as a property since
-    // that is used in the block template.
-    $block->subject = $array['subject'];
-    if ($block->title == '<none>') {
-      $block->subject = '';
+    global $theme_key;
+    $full_block = db_query("SELECT * FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme", array(':module' => $module, ':delta' => $delta, ':theme' => $theme_key))->fetchObject();
+    if (!empty($full_block)) {
+      $block['subject'] = $full_block->title == '<none>' ? '' : check_plain($full_block->title);
     }
 
-    // Run drupal_render on $array['content'];
-    $array['content'] = drupal_render($array['content']);
+    // i18n support.
+    if (function_exists('i18n_block_block_view_alter')) {
+
+      // Check language visibility.
+      global $language;
+      static $block_languages = FALSE;
+      if (!$block_languages) {
+        $block_languages = array();
+        $result = db_query('SELECT module, delta, language FROM {i18n_block_language}');
+        foreach ($result as $record) {
+          $block_languages[$record->module][$record->delta][$record->language] = TRUE;
+        }
+      }
+      if (isset($block_languages[$module][$delta]) && !isset($block_languages[$module][$delta][$language->language])) {
+        return;
+      }
+
+      // Translate.
+      if (!empty($full_block->i18n_mode)) {
+        i18n_block_block_view_alter($block, $full_block);
+        if (!empty($block['title'])) {
+          $block['subject'] = $block['title'];
+        }
+      }
+    }
 
+    $block = (object) $block;
     switch ($field['properties']['block_render']) {
       case DS_BLOCK_TEMPLATE:
-        // Create build array.
-        $elements = array('elements' => array(
-          '#block' => $block,
-          '#subject' => $array['subject'],
-          '#children' => $array['content'])
-        );
+        $block->region = NULL;
+        $block->module = $module;
+        $block->delta = $delta;
+        $elements = array('elements' => array('#block' => $block, '#children' => $block->content));
         // Add contextual links.
-        if (module_exists('contextual') && user_access('access contextual links')) {
-          $elements['elements']['#contextual_links']['block'] = array('admin/structure/block/manage', array($block->module, $block->delta));
+        if ($contextual) {
+          $elements['elements'] += array('#contextual_links' => array_merge($contextual_links, array('block' => array('admin/structure/block/manage', array($block->module, $block->delta)))));
         }
         return theme('block', $elements);
         break;
       case DS_BLOCK_TITLE_CONTENT:
-        return '<h2 class="block-title">' . $array['subject'] . '</h2>' . $array['content'];
+        return '<h2 class="block-title">' . $block->subject . '</h2>' . $block->content;
         break;
       case DS_BLOCK_CONTENT:
-        return $array['content'];
+        return $block->content;
         break;
     }
   }
