X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Ftranslate%2Fsetup.php;h=c33becb95fd5651dc9f702a49d2f60ba4c5df604;hp=26d57590488b0afd4501f6b4157ebc286df31560;hb=55e346263751f3100c780b2d3aee268b6fa3232d;hpb=1ba8cd6be9ab9e969978e0149e79b82769c199d3 diff --git a/plugins/translate/setup.php b/plugins/translate/setup.php index 26d57590..c33becb9 100644 --- a/plugins/translate/setup.php +++ b/plugins/translate/setup.php @@ -3,487 +3,87 @@ /** * setup.php * - * Copyright (c) 1999-2002 The SquirrelMail Project Team - * Licensed under the GNU GPL. For full terms see the file COPYING. + * Easy plugin that sends the body of the message to a new browser + * window using the specified translator. * - * $Id$ + * Translation of composed messages is not supported. + * + * @copyright 1999-2011 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package plugins + * @subpackage translate */ -/* Easy plugin that sends the body of the message to a new browser -window using the specified translator. It can also translate your -outgoing message if you send it to someone in a different country. - - Languages from i18n, incorporated in the auto-language selection: - en - English - no - Norwegian (Bokmål) - no_NO_ny - Norwegian (Nynorsk) - de - Deutsch - ru - Russian KOI8-R - pl - Polish - sv - Swedish - nl - Dutch - pt_BR - Portuguese (Brazil) - fr - French - it - Italian - cs - Czech - es - Spanish - ko - Korean -*/ - -/* Initialize the translation plugin */ +/** + * Initialize the translation plugin + * @return void + * @access private + */ function squirrelmail_plugin_init_translate() { global $squirrelmail_plugin_hooks; $squirrelmail_plugin_hooks['read_body_bottom']['translate'] = 'translate_read_form'; $squirrelmail_plugin_hooks['optpage_register_block']['translate'] = 'translate_optpage_register_block'; $squirrelmail_plugin_hooks['loading_prefs']['translate'] = 'translate_pref'; - $squirrelmail_plugin_hooks['compose_button_row']['translate'] = 'translate_button'; + $squirrelmail_plugin_hooks['options_save']['translate'] = 'translate_save'; + $squirrelmail_plugin_hooks['optpage_set_loadinfo']['translate'] = 'translate_set_loadinfo'; + // $squirrelmail_plugin_hooks['compose_button_row']['translate'] = 'translate_button'; } - -/* Show the translation for a message you're reading */ +/** + * Shows translation box in message display window + * @access private + */ function translate_read_form() { - global $color, $translate_server; - global $body, $translate_dir; - global $translate_show_read; - - if (!$translate_show_read) { - return; - } - - $translate_dir = 'to'; - - $new_body = $body; - $pos = strpos($new_body, - '">'. _("Download this as a file") . ''); - if (is_int($pos)) { - $new_body = substr($new_body, 0, $pos); - } - - $trans = get_html_translation_table(HTML_ENTITIES); - $trans[' '] = ' '; - $trans = array_flip($trans); - $new_body = strtr($new_body, $trans); - - $new_body = urldecode($new_body); - $new_body = strip_tags($new_body); - - /* I really don't like this next part ... */ - $new_body = str_replace('"', "''", $new_body); - $new_body = strtr($new_body, "\n", ' '); - - $function = 'translate_form_' . $translate_server; - $function($new_body); + include_once(SM_PATH . 'plugins/translate/functions.php'); + translate_read_form_function(); } -function translate_table_end() { - ?> - - - - - - - _("Translation Options"), - 'url' => '../plugins/translate/options.php', - 'desc' => _("Which translator should be used when you get messages in a different language?"), - 'js' => false - ); -} - -function translate_pref() { - global $username, $data_dir; - global $translate_server, $translate_location; - global $translate_show_send, $translate_show_read; - global $translate_same_window; - - $translate_server = getPref($data_dir, $username, 'translate_server'); - if ($translate_server == '') { - $translate_server = 'babelfish'; - } - - $translate_location = getPref($data_dir, $username, 'translate_location'); - if ($translate_location == '') { - $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'); + include_once(SM_PATH . 'plugins/translate/functions.php'); + translate_optpage_function(); } - /** - * This function could be sped up. - * It basically negates the process if a ! is found in the beginning and - * matches a * at the end with 0 or more characters. + * Calls user's translation preferences function + * @access private */ -function translate_does_it_match_language($test) { - global $squirrelmail_language; - $true = 1; - $false = 0; - $index = 0; - $smindex = 0; - - if (! $test || ! $squirrelmail_language) { - return $false; - } - - if ($test[$index] == '!') { - $index ++; - $true = 0; - $false = 1; - } - - if (($index == 0) && ($test == $squirrelmail_language)) { - return $true; - } - - while ($test[$index]) { - if ($test[$index] == '*') { - return $true; - } - if ($test[$index] != $squirrelmail_language[$smindex]) { - return $false; - } - $index ++; - $smindex ++; - } - - return $false; +function translate_pref() { + include_once(SM_PATH . 'plugins/translate/functions.php'); + translate_pref_function(); } - -function translate_lang_opt($from, $to, $value, $text) { - global $translate_dir; - - $ret = ' \n"; - - return( $ret ); -} - - -function translate_new_form($action) { - global $translate_dir, $translate_new_window, $translate_location; - global $color, $translate_same_window; - - echo '\n"; - - ?>> - - - - - - - - - - '. - 'Babelfish: '; - - translate_table_end(); -} - -function translate_form_go($message) { - translate_new_form('http://translator.go.com/cb/trans_entry'); -?> - - '. - "". - 'Go.com: '; - - translate_table_end(); -} - -function translate_form_intertran($message) { - translate_new_form('http://www.tranexp.com:2000/InterTran'); - echo ''. - ''. - ""; - - $left = '' . - translate_lang_opt('pt_BR', '', 'pob', _("Brazilian Portuguese")). - translate_lang_opt('', '', 'bul', _("Bulgarian") . ' (CP 1251)'). - translate_lang_opt('', '', 'cro', _("Croatian") . ' (CP 1250)'). - translate_lang_opt('cs', '', 'che', _("Czech") . ' (CP 1250)'). - translate_lang_opt('', '', 'dan', _("Danish")). - translate_lang_opt('nl', '', 'dut', _("Dutch")). - translate_lang_opt('en', '!en', 'eng', _("English")). - translate_lang_opt('', '', 'spe', _("European Spanish")). - translate_lang_opt('', '', 'fin', _("Finnish")). - translate_lang_opt('fr', '', 'fre', _("French")). - translate_lang_opt('de', '', 'ger', _("German")). - translate_lang_opt('', '', 'grk', _("Greek")). - translate_lang_opt('', '', 'hun', _("Hungarian") . ' (CP 1250)'). - translate_lang_opt('', '', 'ice', _("Icelandic")). - translate_lang_opt('it', '', 'ita', _("Italian")). - translate_lang_opt('', '', 'jpn', _("Japanese") . ' (Shift JIS)'). - translate_lang_opt('', '', 'spl', _("Latin American Spanish")). - translate_lang_opt('no*', '', 'nor', _("Norwegian")). - translate_lang_opt('pl', '', 'pol', _("Polish") . ' (ISO 8859-2)'). - translate_lang_opt('', '', 'poe', _("Portuguese")). - translate_lang_opt('', '', 'rom', _("Romanian") . ' (CP 1250)'). - translate_lang_opt('ru', '', 'rus', _("Russian") . ' (CP 1251)'). - translate_lang_opt('', '', 'sel', _("Serbian") . ' (CP 1250)'). - translate_lang_opt('', '', 'slo', _("Slovenian") . ' (CP 1250)'). - translate_lang_opt('es', '', 'spa', _("Spanish")). - translate_lang_opt('sv', '', 'swe', _("Swedish")). - translate_lang_opt('', '', 'wel', _("Welsh")). - ''; - - $right = ''. - translate_lang_opt('', 'pt_BR', 'pob', _("Brazilian Portuguese")). - translate_lang_opt('', '', 'bul', _("Bulgarian") . ' (CP 1251)'). - translate_lang_opt('', '', 'cro', _("Croatian") . ' (CP 1250)'). - translate_lang_opt('', 'cs', 'che', _("Czech") . ' (CP 1250)'). - translate_lang_opt('', '', 'dan', _("Danish")). - translate_lang_opt('', 'nl', 'dut', _("Dutch")). - translate_lang_opt('!en', 'en', 'eng', _("English")). - translate_lang_opt('', '', 'spe', _("European Spanish")). - translate_lang_opt('', '', 'fin', _("Finnish")). - translate_lang_opt('', 'fr', 'fre', _("French")). - translate_lang_opt('', 'de', 'ger', _("German")). - translate_lang_opt('', '', 'grk', _("Greek")). - translate_lang_opt('', '', 'hun', _("Hungarian") . ' (CP 1250)'). - translate_lang_opt('', '', 'ice', _("Icelandic")). - translate_lang_opt('', 'it', 'ita', _("Italian")). - translate_lang_opt('', '', 'jpn', _("Japanese") . ' (Shift JIS)'). - translate_lang_opt('', '', 'spl', _("Latin American Spanish")). - translate_lang_opt('', 'no*', 'nor', _("Norwegian")). - translate_lang_opt('', 'pl', 'pol', _("Polish") . ' (ISO 8859-2)'). - translate_lang_opt('', '', 'poe', _("Portuguese")). - translate_lang_opt('', '', 'rom', _("Romanian") . ' (CP 1250)'). - translate_lang_opt('', 'ru', 'rus', _("Russian") . ' (CP 1251)'). - translate_lang_opt('', '', 'sel', _("Serbian") . ' (CP 1250)'). - translate_lang_opt('', '', 'slo', _("Slovenian") . ' (CP 1250)'). - translate_lang_opt('', 'es', 'spa', _("Spanish")). - translate_lang_opt('', 'sv', 'swe', _("Swedish")). - translate_lang_opt('', '', 'wel', _("Welsh")). - ''; - printf( _("%s to %s"), $left, $right ); - echo 'InterTran: '; - - translate_table_end(); -} - -function translate_form_gpltrans($message) { - translate_new_form('http://www.translator.cx/cgi-bin/gplTrans'); - echo ''; - translate_lang_opt('en', '!en', 'no', 'From English'); - translate_lang_opt('!en', 'en', 'yes', 'To English'); - echo ''. - translate_lang_opt('nl', 'nl', 'dutch_dict', _("Dutch")). - translate_lang_opt('fr', 'fr', 'french_dict', _("French")). - translate_lang_opt('de', 'de', 'german_dict', _("German")). - translate_lang_opt('', '', 'indonesian_dict', _("Indonesian")). - translate_lang_opt('it', 'it', 'italian_dict', _("Italian")). - translate_lang_opt('', '', 'latin_dict', _("Latin")). - translate_lang_opt('pt', 'pt', 'portuguese_dict', _("Portuguese")). - translate_lang_opt('es', 'es', 'spanish_dict', _("Spanish")). - ''. - "". - 'GPLTrans: '; - - translate_table_end(); +/** + * Calls user's translation preferences saving function + * @access private + */ +function translate_save() { + include_once(SM_PATH . 'plugins/translate/functions.php'); + translate_save_function(); } -function translate_form_dictionary($message) { - translate_new_form('http://translate.dictionary.com:8800/systran/cgi'); - echo ''. - "". - ''. - translate_lang_opt('en', 'fr', 'en_fr', - sprintf( _("%s to %s"), - _("English"), - _("French"))) . - translate_lang_opt('', 'de', 'en_de', - sprintf( _("%s to %s"), - _("English"), - _("German"))) . - translate_lang_opt('', 'it', 'en_it', - sprintf( _("%s to %s"), - _("English"), - _("Italian"))) . - translate_lang_opt('', 'pt*', 'en_pt', - sprintf( _("%s to %s"), - _("English"), - _("Portuguese"))) . - translate_lang_opt('', 'es', 'en_sp', - sprintf( _("%s to %s"), - _("English"), - _("Spanish"))) . - translate_lang_opt('fr', '', 'fr_en', - sprintf( _("%s to %s"), - _("French"), - _("English"))) . - translate_lang_opt('', '', 'fr_ge', - sprintf( _("%s to %s"), - _("French"), - _("German"))) . - translate_lang_opt('', '', 'ge_fr', - sprintf( _("%s to %s"), - _("German"), - _("French"))) . - translate_lang_opt('de', '', 'de_en', - sprintf( _("%s to %s"), - _("German"), - _("English"))) . - translate_lang_opt('it', '', 'it_en', - sprintf( _("%s to %s"), - _("Italian"), - _("English"))) . - translate_lang_opt('pt*', '', 'pt_en', - sprintf( _("%s to %s"), - _("Portuguese"), - _("English"))) . - translate_lang_opt('es', '', 'sp_en', - sprintf( _("%s to %s"), - _("Spanish"), - _("English"))) . - ''. - 'Dictionary.com: '; - - translate_table_end(); +/** + * Calls user's translation preferences set_loadinfo function + * @access private + */ +function translate_set_loadinfo() { + include_once(SM_PATH . 'plugins/translate/functions.php'); + translate_set_loadinfo_function(); } -?>