Use compatibility_info() function if at all possible instead of compatibility_version()
[squirrelmail.git] / plugins / translate / functions.php
index bd7616f2a2e8a66a008b6e3049ddddf1e3ae1749..0d77939d0f0a1ed48be95469b70c444deab1724b 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * SquirrelMail translate plugin functions
  *
- * @copyright © 2004-2006 The SquirrelMail Project Team
+ * @copyright © 2004-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
  */
 
 /**
- * Define for wrecked souls accessing functions script directly
- * @ignore
+ * do not allow to call this file directly
  */
-if (!defined('SM_PATH'))  {
-    define('SM_PATH','../../');
+if ((isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) ||
+     (isset($HTTP_SERVER_SERVER['SCRIPT_FILENAME']) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) {
+    header("Location: ../../src/login.php");
+    die();
 }
-
 /** Load default config */
 if (file_exists(SM_PATH . 'plugins/translate/config_default.php')) {
     include_once(SM_PATH . 'plugins/translate/config_default.php');
@@ -85,7 +85,7 @@ function translate_read_form_function() {
     $translate_server_option='translate_' . $translate_server . '_enabled';
     if ($translate_server=='gpltrans' && $translate_gpltrans_url=='' ||
         ! $$translate_server_option || ! function_exists('translate_form_' . $translate_server)) {
-        error_box(_("Selected translation engine is disabled. Please update your translation preferences."),$color);
+        error_box(_("Selected translation engine is disabled. Please update your translation preferences."));
         return;
     }
     $translate_dir = 'to';
@@ -93,7 +93,7 @@ function translate_read_form_function() {
     $trans_ar = $message->findDisplayEntity(array(), array('text/plain'));
     $body = '';
     $final_body = '';
-    if ($trans_ar[0] != '') {
+    if ( !empty($trans_ar[0]) ) {
         for ($i = 0; $i < count($trans_ar); $i++) {
             /* reduced version of formatBody and translateText functions */
 
@@ -105,7 +105,7 @@ function translate_read_form_function() {
             $body = decodeBody($body, $body_message->header->encoding);
 
             /*
-             * if message part is html formated - convert spaces, html line feeds, 
+             * if message part is html formated - convert spaces, html line feeds,
              * less than and greater than html entities and remove tags
              */
             if ($body_message->header->type1 == 'html') {
@@ -284,7 +284,7 @@ function translate_showtrad() {
               'http://www.dictionary.com/translate' );
     if ($translate_google_enabled) translate_showtrad_internal( 'Google Translate',
               _("No known limits, powered by Systran").
-              '<br />'.sprintf(_("Number of supported language pairs: %s"),'12').' ' ,
+              '<br />'.sprintf(_("Number of supported language pairs: %s"),'20').' ' ,
               'http://www.google.com/translate' );
     if ($translate_gpltrans_enabled && $translate_gpltrans_url!='') translate_showtrad_internal( 'GPLTrans',
               _("No known limits, powered by GPLTrans (free, open source)").
@@ -434,7 +434,7 @@ function translate_lang_opt($from, $to, $value, $text) {
  * Starts translation box
  *
  * @param string $action url that has to recieve message for translation
- * @param string $charset (since sm 1.5.1) character set, that should be used 
+ * @param string $charset (since sm 1.5.1) character set, that should be used
  * to submit 8bit information.
  * @access private
  */
@@ -455,7 +455,7 @@ function translate_new_form($action,$charset=null) {
     if (!$translate_same_window) {
         echo ' target="_blank"';
     }
-    
+
     if (! is_null($charset))
         echo ' accept-charset="'.htmlspecialchars($charset).'"';
 
@@ -909,10 +909,7 @@ function translate_form_promt($message) {
  */
 function translate_form_google($message) {
     translate_new_form('http://www.google.com/translate_t','utf-8');
-    echo '<input type="hidden" name="ie" value="Unknown" />' .
-         '<input type="hidden" name="oe" value="ASCII" />' .
-         '<input type="hidden" name="hl" value="en" />' .
-         '<input type="hidden" name="text" value="' . $message . '" />';
+    echo '<input type="hidden" name="text" value="' . $message . '" />';
     echo '<select name="langpair">'.
          translate_lang_opt('en_US', 'de_DE', 'en|de',
                             sprintf( _("%s to %s"),_("English"),_("German"))) .
@@ -924,6 +921,14 @@ function translate_form_google($message) {
                             sprintf( _("%s to %s"),_("English"),_("Italian"))) .
          translate_lang_opt('en_US', 'pt*',   'en|pt',
                             sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
+         translate_lang_opt('en_US', 'ar',    'en|ar',
+                            sprintf( _("%s to %s"),_("English"),_("Arabic"))) .
+         translate_lang_opt('en_US', 'ja_JP', 'en|ja',
+                            sprintf( _("%s to %s"),_("English"),_("Japanese"))) .
+         translate_lang_opt('en_US', 'ko_KR', 'en|ko',
+                            sprintf( _("%s to %s"),_("English"),_("Korean"))) .
+         translate_lang_opt('en_US', 'zh_CN', 'en|zh-CN',
+                            sprintf( _("%s to %s"),_("English"),_("Chinese (Simplified)"))) .
          translate_lang_opt('de_DE', 'en_US', 'de|en',
                             sprintf( _("%s to %s"),_("German"),_("English"))) .
          translate_lang_opt('de_DE', '', 'de|fr',
@@ -937,10 +942,20 @@ function translate_form_google($message) {
          translate_lang_opt('it_IT', '', 'it|en',
                             sprintf( _("%s to %s"),_("Italian"),_("English"))) .
          translate_lang_opt('pt*',   '', 'pt|en',
-                            sprintf( _("%s to %s"),_("Portuguese"),_("English")));
+                            sprintf( _("%s to %s"),_("Portuguese"),_("English"))).
+         translate_lang_opt('ar',    '', 'ar|en',
+                            sprintf( _("%s to %s"),_("Arabic"),_("English"))).
+         translate_lang_opt('ja_JP', '', 'ja|en',
+                            sprintf( _("%s to %s"),_("Japanese"),_("English"))).
+         translate_lang_opt('ko_KR', '', 'ko|en',
+                            sprintf( _("%s to %s"),_("Korean"),_("English"))).
+         translate_lang_opt('zh_CN', '', 'zh-CN|en',
+                            sprintf( _("%s to %s"),_("Chinese (Simplified)"),_("English")));
     echo '</select>'.
-         'Google: <input type="submit" value="' . _("Translate") . '" />';
+        '<input type="hidden" name="hl" value="en" />' .
+        '<input type="hidden" name="ie" value="UTF8" />' .
+        '<input type="hidden" name="oe" value="UTF8" />' .
+        'Google: <input type="submit" value="' . _("Translate") . '" />';
 
     translate_table_end();
 }
-?>