From 08523485f2344482ee7e8726573629e1e1ee8e46 Mon Sep 17 00:00:00 2001
From: James Sansbury <james.sansbury@lullabot.com>
Date: Mon, 29 Apr 2013 10:47:17 -0400
Subject: [PATCH] Issue #1685144 by marcelovani, dawehner, q0rban: Refactor
 init_localization() to init and return the translate
 property for all plugins.

---
 includes/view.inc |   27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/includes/view.inc b/includes/view.inc
index d8c0c1f..2405b8d 100644
--- a/includes/view.inc
+++ b/includes/view.inc
@@ -2076,25 +2076,26 @@ class view extends views_db_object {
   }
 
   /**
-   * Find and initialize the localizer plugin.
+   * Find and initialize the localization plugin.
    */
   function init_localization() {
-    if (isset($this->localization_plugin) && is_object($this->localization_plugin)) {
-      return TRUE;
-    }
+    // If the translate attribute isn't set, init the localization plugin.
+    if (!isset($this->localization_plugin->translate)) {
+      $this->localization_plugin = views_get_plugin('localization', views_get_localization_plugin());
 
-    $this->localization_plugin = views_get_plugin('localization', views_get_localization_plugin());
+      // If the plugin is still not set, turn off all localization by using the
+      // views_plugin_localization_none plugin. This plugin has the translate
+      // property set to FALSE, signifying localization should not occur.
+      if (empty($this->localization_plugin)) {
+        $this->localization_plugin = views_get_plugin('localization', 'none');
+      }
 
-    if (empty($this->localization_plugin)) {
-      $this->localization_plugin = views_get_plugin('localization', 'none');
-      return FALSE;
+      // Init the plugin.
+      $this->localization_plugin->init($this);
     }
 
-    /**
-    * Figure out whether there should be options.
-    */
-    $this->localization_plugin->init($this);
-
+    // Return the value of the translate property. This is set to FALSE if
+    // localization is off.
     return $this->localization_plugin->translate;
   }
 
-- 
1.7.10.4

