findDisplayEntity(array(), array('text/plain')); $body = ''; $final_body = ''; if ( !empty($trans_ar[0]) ) { for ($i = 0; $i < count($trans_ar); $i++) { /* reduced version of formatBody and translateText functions */ // get message entity information $body_message = getEntity($message, $trans_ar[$i]); // get message body $body = mime_fetch_body ($imapConnection, $passed_id, $trans_ar[$i]); // convert encoded messages $body = decodeBody($body, $body_message->header->encoding); /* * 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') { $entity_conv = array(' ' => ' ', '

' => "\n", '

' => "\n", '
' => "\n", '
' => "\n", '
' => "\n", '
' => "\n", '>' => '>', '<' => '<'); $body = strtr($body, $entity_conv); $body = strip_tags($body); } // remove whitespace $body = trim($body); // save processed text and parse other entity $final_body.= charset_decode($body_message->header->getParameter('charset'),$body); } // add form if message is not empty if (!empty($final_body)) { $function = 'translate_form_' . $translate_server; $function($final_body); } } } /** * Adds translation option block * @access private */ function translate_optpage_function() { global $optpage_blocks; $optpage_blocks[] = array( 'name' => _("Translation Options"), 'url' => '../plugins/translate/options.php', 'desc' => _("Which translator should be used when you get messages in a different language?"), 'js' => false ); } /** * Gets user's translation preferences * @access private */ function translate_pref_function() { global $username, $data_dir; global $translate_server, $translate_location; global $translate_show_send, $translate_show_read; global $translate_same_window,$translate_default_engine; $translate_server = getPref($data_dir, $username, 'translate_server',$translate_default_engine); $translate_location = getPref($data_dir, $username, 'translate_location','center'); $translate_show_send = getPref($data_dir, $username, 'translate_show_send'); $translate_show_read = getPref($data_dir, $username, 'translate_show_read'); $translate_same_window = getPref($data_dir, $username, 'translate_same_window'); } /** * Should add translation options in compose window * * Unimplemented * @access private */ function translate_button_function() { global $translate_show_send; if (! $translate_show_send) { return; } } /** * Save translation options */ function translate_save_function() { global $username, $data_dir; // Save preferences if (sqgetGlobalVar('submit_translate',$tmp,SQ_POST)) { if (sqgetGlobalVar('translate_translate_server',$translate_server,SQ_POST)) { setPref($data_dir, $username, 'translate_server', $translate_server); } else { setPref($data_dir, $username, 'translate_server', $translate_default_engine); } if (sqgetGlobalVar('translate_translate_location',$translate_location,SQ_POST)) { setPref($data_dir, $username, 'translate_location', $translate_location); } else { setPref($data_dir, $username, 'translate_location', 'center'); } if (sqgetGlobalVar('translate_translate_show_read',$translate_show_read,SQ_POST)) { setPref($data_dir, $username, 'translate_show_read', '1'); } else { setPref($data_dir, $username, 'translate_show_read', ''); } if (sqgetGlobalVar('translate_translate_show_send',$translate_show_send,SQ_POST)) { setPref($data_dir, $username, 'translate_show_send', '1'); } else { setPref($data_dir, $username, 'translate_show_send', ''); } if (sqgetGlobalVar('translate_translate_same_window',$translate_same_windows,SQ_POST)) { setPref($data_dir, $username, 'translate_same_window', '1'); } else { setPref($data_dir, $username, 'translate_same_window', ''); } } } /** * Set option page name * @access private */ function translate_set_loadinfo_function() { global $optpage, $optpage_name; if ($optpage=='translate') { $optpage_name=_("Translation Preferences"); } } /** Option functions */ /** * Creates server selection options * @access private */ function translate_showoption() { global $translate_babelfish_enabled, $translate_go_enabled, $translate_dictionary_enabled, $translate_google_enabled, $translate_gpltrans_enabled, $translate_intertran_enabled, $translate_promt_enabled, $translate_otenet_enabled; global $translate_custom_enabled, $translate_gpltrans_url; if ($translate_babelfish_enabled) translate_showoption_internal('server','babelfish', 'Babelfish'); if ($translate_go_enabled) translate_showoption_internal('server','go', 'Go.com'); if ($translate_dictionary_enabled) translate_showoption_internal('server','dictionary', 'Dictionary.com'); if ($translate_google_enabled) translate_showoption_internal('server','google', 'Google Translate'); if ($translate_gpltrans_enabled && $translate_gpltrans_url!='') translate_showoption_internal('server','gpltrans', 'GPLTrans'); if ($translate_intertran_enabled) translate_showoption_internal('server','intertran', 'Intertran'); if ($translate_otenet_enabled) translate_showoption_internal('server','otenet', 'OTEnet'); if ($translate_promt_enabled) translate_showoption_internal('server','promt', 'PROMT'); if ($translate_custom_enabled && function_exists('translate_custom_showoption')) { translate_custom_showoption(); } } /** * Displays comments about available translation engines * @access private */ function translate_showtrad() { global $translate_babelfish_enabled, $translate_go_enabled, $translate_dictionary_enabled, $translate_google_enabled, $translate_gpltrans_enabled, $translate_intertran_enabled, $translate_promt_enabled, $translate_otenet_enabled; global $translate_gpltrans_url, $translate_custom_enabled; if ($translate_babelfish_enabled) translate_showtrad_internal( 'Babelfish', _("Maximum of 150 words translated, powered by Systran"). '
'.sprintf(_("Number of supported language pairs: %s"),'36').' ' , 'http://babelfish.altavista.com/' ); if ($translate_go_enabled) translate_showtrad_internal( 'Translator.Go.com', _("Maximum of 25 kilobytes translated, powered by Systran"). '
'.sprintf(_("Number of supported language pairs: %s"),'10').' ' , 'http://translator.go.com/' ); if ($translate_dictionary_enabled) translate_showtrad_internal( 'Dictionary.com', _("No known limits, powered by Systran"). '
'.sprintf(_("Number of supported language pairs: %s"),'24').' ' , 'http://www.dictionary.com/translate' ); if ($translate_google_enabled) translate_showtrad_internal( 'Google Translate', _("No known limits, powered by Systran"). '
'.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)"). '
'.sprintf(_("Number of supported language pairs: %s"),'16').' ' , 'http://www.translator.cx/' ); if ($translate_intertran_enabled) translate_showtrad_internal( 'InterTran', _("No known limits, powered by Translation Experts' InterTran"). '
'.sprintf(_("Number of supported languages: %s"),'29').' ' , 'http://www.tranexp.com/' ); if ($translate_otenet_enabled) translate_showtrad_internal( 'OTEnet', _("Hellenic translations, no known limits, powered by Systran"). '
'.sprintf(_("Number of supported language pairs: %s"),'20').' ' , 'http://systran.otenet.gr/' ); if ($translate_promt_enabled) translate_showtrad_internal( 'PROMT', _("Russian translations, maximum of 500 characters translated"). '
'.sprintf(_("Number of supported language pairs: %s"),'16').' ' , 'http://www.online-translator.com/' ); if ($translate_custom_enabled && function_exists('translate_custom_showtrad')) { translate_custom_showtrad(); } } /** * Creates options for translation selection boxes * @param string $Var option type (server,location) * @param string $value option value * @param string $Desc description of translation server * @access private * @since 1.5.1 */ function translate_showoption_internal($Var,$value, $Desc) { $Var='translate_' . $Var; global $$Var; echo '\n"; } /** * Creates translation server description * @param string $tit title * @param string $com comments about translation server * @param string $url url of translation server * @access private */ function translate_showtrad_internal( $tit, $com, $url ) { echo "

  • $tit - ". $com . "[ $tit ]
  • "; } /** Internal functions */ /** * Closes table tags in translation box * @access private */ function translate_table_end() { ?> ' . $text . "\n"; return( $ret ); } /** * 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 * to submit 8bit information. * @access private */ function translate_new_form($action,$charset=null) { global $translate_dir, $translate_location; global $color, $translate_same_window; echo '
    \n"; ?>
    '; translate_table_end(); } /** * go.com translation engine (disabled) * * @param string $message text that has to be translated * @access private */ function translate_form_go($message) { translate_new_form('http://translator.go.com/cb/trans_entry'); ?> '. 'Go.com: '; translate_table_end(); } /** * intertran translation engine * * @param string $message text that has to be translated * @access private */ function translate_form_intertran($message) { translate_new_form('http://intertran.tranexp.com/Translate/result.shtml'); echo ''. ''. ''. ''; $left = ''; $right = ''; printf( _("%s to %s"), $left, $right ); echo 'InterTran: '; translate_table_end(); } /** * gpltrans translation engine * * @param string $message text that has to be translated * @access private */ function translate_form_gpltrans($message) { global $translate_gpltrans_url; // make sure that it is not empty if ($translate_gpltrans_url=='') $translate_gpltrans_url='http://www.translator.cx/cgi-bin/gplTrans'; translate_new_form($translate_gpltrans_url); echo ''; echo ''; echo ''. 'GPLTrans: '; translate_table_end(); } /** * reference.com (dictionary) translation engine * * @param string $message text that has to be translated * @access private */ function translate_form_dictionary($message) { translate_new_form('http://dictionary.reference.com/translate/text.html'); list($usec, $sec) = explode(' ',microtime()); $time = $sec . (float)$usec*100000000; echo ''. ''. ''. 'Dictionary.com: '; translate_table_end(); } /** * otenet translation engine * * @param string $message text that has to be translated * @access private */ function translate_form_otenet($message) { translate_new_form('http://trans.otenet.gr/systran/box','windows-1253'); ?> '; translate_table_end(); } /** * promt translation engine * * @param string $message text that has to be translated * @access private */ function translate_form_promt($message) { translate_new_form('http://www.online-translator.com/text.asp#tr_form','windows-1251'); echo ''; echo ''; echo _("Interface language")." : "; echo "
    \n"; echo _("Translation direction")." : "; echo '
    \n"; echo "\n"; echo _("Transliterate unknown words:") . '
    '; echo 'PROMT: '; translate_table_end(); } /** * google translation engine * * @param string $message text that has to be translated * @access private */ function translate_form_google($message) { translate_new_form('http://www.google.com/translate_t','utf-8'); echo ''; echo ''. '' . '' . '' . 'Google: '; translate_table_end(); }