View Issue Details

IDProjectCategoryView StatusLast Update
0015458phplist applicationPlugin APIpublic31-05-12 13:01
Reporteradrian15 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product VersionFutureDevelopments 
Target Version4.0.xFixed in Version2.11.7 
Summary0015458: Extend i18n functionality for plugins
DescriptionThis patch extends i18n functionality. If you apply my former displayHeader patch you find out that plugins cannot apply their own i18n in their text hooks.

This patch solves this problem by enabling i18n hook based on a new folder called: main_lan (or whatever name the plugin decides) inside the plugin folder itself.
Additional Information* This patch was designed with svn revision 1703 in mind. I suppose it will work in any 2.11 version (aka current svn) but it will fail in 2.10 version because I have read somewhere that there were many changes from the 2.10 to the 2.11 plugin management, but you are free to try it.

* This patch is needed for the wizard so please relate it to issue: #15457.
TagsNo tags attached.

Relationships

related to 0015459 new Wizard plugin 

Activities

27-04-10 11:54

 

wizard_D03_plugins_extended_i18n_support.patch (6,082 bytes)
diff -urN wizard_D02_add_header/lists/admin/defaultplugin.php wizard_D03_plugins_i18n/lists/admin/defaultplugin.php
--- wizard_D02_add_header/lists/admin/defaultplugin.php	2010-04-12 18:29:19.000000000 +0200
+++ wizard_D03_plugins_i18n/lists/admin/defaultplugin.php	2010-04-27 12:44:57.000000000 +0200
@@ -54,6 +54,11 @@
     return null;
   }
 
+  function i18nLanguageDir() {
+    # Return i18n Language Dir so that main page content can be extended
+    return null;
+  }
+
   function writeConfig($name, $value) {
     #  write a value to the general config to be retrieved at a later stage
     # parameters: name -> name of the variable
diff -urN wizard_D02_add_header/lists/admin/languages.php wizard_D03_plugins_i18n/lists/admin/languages.php
--- wizard_D02_add_header/lists/admin/languages.php	2010-04-12 18:17:36.000000000 +0200
+++ wizard_D03_plugins_i18n/lists/admin/languages.php	2010-04-27 12:44:57.000000000 +0200
@@ -203,62 +203,69 @@
     else
       $page = "home";
 
-    if (!empty($_GET['pi'])) {
-      $plugin_languagedir = $this->getPluginBasedir();
-      if (is_dir($plugin_languagedir)) {
-        $this->basedir = $plugin_languagedir;
+    foreach ($GLOBALS['plugins'] as $pluginName=>$plugin) {
+      if ( $plugin->i18nLanguageDir() ){
+	$this->basedir=$plugin->i18nLanguageDir();
       }
-    }
-    
-    if (trim($text) == "") return "";
-    if (strip_tags($text) == "") return $text;
-    if (is_file($this->basedir.$this->language.'/'.$page.'.php')) {
-      @include $this->basedir.$this->language.'/'.$page.'.php';
-    } elseif (!isset($GLOBALS['developer_email'])) {
-      @include $this->basedir.$this->defaultlanguage.'/'.$page.'.php';
-    }
-    if (isset($lan) && is_array($lan) && isset($lan[$text])) {
-      return $this->formatText($lan[$text]);
-    }
-    if (isset($lan) && is_array($lan) && isset($lan[strtolower($text)])) {
-      return $this->formatText($lan[strtolower($text)]);
-    }
-    if (isset($lan) && is_array($lan) && isset($lan[strtoupper($text)])) {
-      return $this->formatText($lan[strtoupper($text)]);
-    }
-    if (is_file($this->basedir.$this->language.'/common.php')) {
-      @include $this->basedir.$this->language.'/common.php';
-    } elseif (!isset($GLOBALS['developer_email'])) {
-      @include $this->basedir.$this->defaultlanguage.'/common.php';
-    }
-    if (isset($lan) && is_array($lan) && isset($lan[$text])) {
-      return $this->formatText($lan[$text]);
-    }
-    if (isset($lan) && is_array($lan) && isset($lan[strtolower($text)])) {
-      return $this->formatText($lan[strtolower($text)]);
-    }
-    if (isset($lan) && is_array($lan) && isset($lan[strtoupper($text)])) {
-      return $this->formatText($lan[strtoupper($text)]);
-    }
 
-    if (is_file($this->basedir.$this->language.'/frontend.php')) {
-      @include $this->basedir.$this->language.'/frontend.php';
-    } elseif (!isset($GLOBALS['developer_email'])) {
-      @include $this->basedir.$this->defaultlanguage.'/frontend.php';
-    }
-    if (isset($lan) && is_array($lan) && isset($lan[$text])) {
-      return $this->formatText($lan[$text]);
-    }
-    if (isset($lan) && is_array($lan) && isset($lan[strtolower($text)])) {
-      return $this->formatText($lan[strtolower($text)]);
-    }
-    if (isset($lan) && is_array($lan) && isset($lan[strtoupper($text)])) {
-      return $this->formatText($lan[strtoupper($text)]);
-    }
-  
-    # spelling mistake, retry with old spelling
-    if ($text == 'over threshold, user marked unconfirmed') {
-      return $this->get('over treshold, user marked unconfirmed');
+
+      if (!empty($_GET['pi'])) {
+	$plugin_languagedir = $this->getPluginBasedir();
+	if (is_dir($plugin_languagedir)) {
+	  $this->basedir = $plugin_languagedir;
+	}
+      }
+      
+      if (trim($text) == "") return "";
+      if (strip_tags($text) == "") return $text;
+      if (is_file($this->basedir.$this->language.'/'.$page.'.php')) {
+	@include $this->basedir.$this->language.'/'.$page.'.php';
+      } elseif (!isset($GLOBALS['developer_email'])) {
+	@include $this->basedir.$this->defaultlanguage.'/'.$page.'.php';
+      }
+      if (isset($lan) && is_array($lan) && isset($lan[$text])) {
+	return $this->formatText($lan[$text]);
+      }
+      if (isset($lan) && is_array($lan) && isset($lan[strtolower($text)])) {
+	return $this->formatText($lan[strtolower($text)]);
+      }
+      if (isset($lan) && is_array($lan) && isset($lan[strtoupper($text)])) {
+	return $this->formatText($lan[strtoupper($text)]);
+      }
+      if (is_file($this->basedir.$this->language.'/common.php')) {
+	@include $this->basedir.$this->language.'/common.php';
+      } elseif (!isset($GLOBALS['developer_email'])) {
+	@include $this->basedir.$this->defaultlanguage.'/common.php';
+      }
+      if (isset($lan) && is_array($lan) && isset($lan[$text])) {
+	return $this->formatText($lan[$text]);
+      }
+      if (isset($lan) && is_array($lan) && isset($lan[strtolower($text)])) {
+	return $this->formatText($lan[strtolower($text)]);
+      }
+      if (isset($lan) && is_array($lan) && isset($lan[strtoupper($text)])) {
+	return $this->formatText($lan[strtoupper($text)]);
+      }
+
+      if (is_file($this->basedir.$this->language.'/frontend.php')) {
+	@include $this->basedir.$this->language.'/frontend.php';
+      } elseif (!isset($GLOBALS['developer_email'])) {
+	@include $this->basedir.$this->defaultlanguage.'/frontend.php';
+      }
+      if (isset($lan) && is_array($lan) && isset($lan[$text])) {
+	return $this->formatText($lan[$text]);
+      }
+      if (isset($lan) && is_array($lan) && isset($lan[strtolower($text)])) {
+	return $this->formatText($lan[strtolower($text)]);
+      }
+      if (isset($lan) && is_array($lan) && isset($lan[strtoupper($text)])) {
+	return $this->formatText($lan[strtoupper($text)]);
+      }
+    
+      # spelling mistake, retry with old spelling
+      if ($text == 'over threshold, user marked unconfirmed') {
+	return $this->get('over treshold, user marked unconfirmed');
+      }
     }
     return $this->missingText($text);
   }

27-04-10 16:28

 

E02_wizard_plugins_i18n_fix.patch (1,840 bytes)
diff -urN wizard2_before/lists/admin/defaultplugin.php wizard2_E02_plugins_i18n_fix/lists/admin/defaultplugin.php
--- wizard2_before/lists/admin/defaultplugin.php	2010-04-12 21:52:31.000000000 +0200
+++ wizard2_E02_plugins_i18n_fix/lists/admin/defaultplugin.php	2010-04-27 17:24:39.000000000 +0200
@@ -19,6 +19,7 @@
   #@@Some ideas to implement this:
   # * Start each method with if (!$this->enabled) return parent :: parentMethod($args);
   # * Don't add to manage Global plugins if disabled
+  var $needI18N=0; // Temporary variable to know if plugin specific i18n is needed
   var $coderoot= "./PLUGIN_ROOTDIR/defaultplugin/"; # coderoot relative to the phplist admin directory
   # optional configuration variables
   var $configvars= array ();
@@ -51,6 +52,9 @@
 
   function displayHeader($info) {
     # Return html snippet to add at header
+    $this->needI18N = 1;
+    # Do stuff here
+    $this->needI18N = 0;
     return null;
   }
 
diff -urN wizard2_before/lists/admin/languages.php wizard2_E02_plugins_i18n_fix/lists/admin/languages.php
--- wizard2_before/lists/admin/languages.php	2010-04-12 21:52:32.000000000 +0200
+++ wizard2_E02_plugins_i18n_fix/lists/admin/languages.php	2010-04-27 17:24:39.000000000 +0200
@@ -204,10 +204,10 @@
       $page = "home";
 
     foreach ($GLOBALS['plugins'] as $pluginName=>$plugin) {
-      if ( $plugin->i18nLanguageDir() ){
+      if ( ($plugin->i18nLanguageDir()) && ($plugin->enabled) && (($plugin->needI18N) === 1) ){
 	$this->basedir=$plugin->i18nLanguageDir();
       }
-
+    }
 
       if (!empty($_GET['pi'])) {
 	$plugin_languagedir = $this->getPluginBasedir();
@@ -266,7 +266,7 @@
       if ($text == 'over threshold, user marked unconfirmed') {
 	return $this->get('over treshold, user marked unconfirmed');
       }
-    }
+
     return $this->missingText($text);
   }
 }

adrian15

27-04-10 16:29

reporter   ~0050970

I have uploaded E02_wizard_plugins_i18n_fix.patch which fine tunes i18n support on plugins so that it is only used when needed.

I had some problems with Spanish language and disabling rssmanager with the former patch.

Both patches should be applied one after the another. I mean, second patch is not a substitute for the first patch.

michiel

31-05-12 13:00

manager   ~0051659

patches applied, as well as I could. They didn't match any longer, but I've tried to fix that manually.

would be good to check if it works for you.

http://phplist.svn.sourceforge.net/phplist/?rev=3277&view=rev