From 859f39476b461bbf84bfa6672944e993ecea4875 Mon Sep 17 00:00:00 2001 From: tokul Date: Sun, 24 Oct 2004 10:57:27 +0000 Subject: [PATCH] adding phpdoc tags. updating translation engines. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@8235 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/translate/INSTALL | 4 + plugins/translate/README | 2 + plugins/translate/config-sample.php | 134 +++++++++++++++++++++ plugins/translate/config_default.php | 36 ++++-- plugins/translate/functions.php | 167 +++++++++++++++++++++------ plugins/translate/options.php | 57 +-------- plugins/translate/setup.php | 22 +++- 7 files changed, 324 insertions(+), 98 deletions(-) create mode 100644 plugins/translate/config-sample.php diff --git a/plugins/translate/INSTALL b/plugins/translate/INSTALL index 945acc9a..8b2604d2 100644 --- a/plugins/translate/INSTALL +++ b/plugins/translate/INSTALL @@ -14,3 +14,7 @@ if the plugin was made correctly. :) $ cd ../config $ ./conf.pl + +Some plugin settings might be adjusted by creating config/translate_config.php or +plugins/translate/config.php configuration file. See plugins/translate/config_default.php +and plugins/translate/config-sample.php diff --git a/plugins/translate/README b/plugins/translate/README index fc271577..1b4a97d7 100644 --- a/plugins/translate/README +++ b/plugins/translate/README @@ -59,6 +59,8 @@ Questions/comments/flames/etc can be sent to the Squirrelmail Plugins list Changes ======= * Plugin included into squirrelmail distribution + * Added site configuration options + 1.3 -> 1.4 * Modified to use new option page hook. Paul Joseph Thompson diff --git a/plugins/translate/config-sample.php b/plugins/translate/config-sample.php new file mode 100644 index 00000000..be27ba7d --- /dev/null +++ b/plugins/translate/config-sample.php @@ -0,0 +1,134 @@ +'; + echo ''; + echo ''; + echo ""; + echo 'Al Misbar: '; + + echo '
'; + echo _("Translation Theme:") . ' '; + echo ''; + echo '
'; + echo ''; + echo "Transliteration of abbreviations"; + echo ''; + echo "Transliteration of proper nouns"; + echo ''; + echo "Show Harakat"; + echo '

'; + + translate_table_end(); +} + +/** + * Add info about almisbar + * + * String is not translated, because config file might be different + */ +function translate_custom_showtrad() { + translate_showtrad_internal( 'Al Misbar', + "English to Arabic translation (powered by Al-Mutarjim (TM) Al-Arabey and Al-Wafi v2 machine translation engine)", + 'http://www.almisbar.com/' ); +} + +/** + * Add almisbar option + */ +function translate_custom_showoption() { + translate_showoption_internal('server', 'custom', 'Al Misbar'); +} +?> \ No newline at end of file diff --git a/plugins/translate/config_default.php b/plugins/translate/config_default.php index b922bcf9..101a74f3 100644 --- a/plugins/translate/config_default.php +++ b/plugins/translate/config_default.php @@ -10,54 +10,67 @@ * @subpackage translate */ -/** */ +/** + * Default translation engine + * @global string $translate_default_engine + */ global $translate_default_engine; $translate_default_engine='babelfish'; /** - * + * Babelfish translation engine controls + * @global boolean $translate_babelfish_enabled */ global $translate_babelfish_enabled; $translate_babelfish_enabled=true; /** + * Go.com translation engine controls * + * Translation is no longer available + * @global boolean $translate_go_enabled */ global $translate_go_enabled; $translate_go_enabled=false; /** - * + * Dictionary.com translation engine controls + * @global boolean $translate_dictionary_enabled */ global $translate_dictionary_enabled; $translate_dictionary_enabled=true; /** - * + * Google translation engine controls + * @global boolean $translate_google_enabled */ global $translate_google_enabled; $translate_google_enabled=true; /** - * + * Intertran translation engine controls + * @global boolean $translate_intertran_enabled */ global $translate_intertran_enabled; $translate_intertran_enabled=true; /** - * + * Promt translation engine controls + * @global boolean $translate_promt_enabled */ global $translate_promt_enabled; $translate_promt_enabled=true; /** - * + * Otenet translation engine controls + * @global boolean $translate_otenet_enabled */ global $translate_otenet_enabled; $translate_otenet_enabled=true; /** - * + * Gpltrans translation engine controls + * @global boolean $translate_gpltrans_enabled */ global $translate_gpltrans_enabled; $translate_gpltrans_enabled=true; @@ -74,7 +87,10 @@ global $translate_gpltrans_url; $translate_gpltrans_url=''; /** + * Translation in compose controls * + * Currently unimplemened and disabled + * @global boolean $disable_compose_translate */ global $disable_compose_translate; $disable_compose_translate=true; @@ -82,10 +98,10 @@ $disable_compose_translate=true; /** Custom translation engine setup */ /** - * Controls inclusion of custom translation engines. + * Controls inclusion of custom translation engine. * * If you enable custon translation engines, you must include - * translate_custom(), translate_custom_showtrad() and + * translate_form_custom(), translate_custom_showtrad() and * $translate_custom_showoption() functions in your config. * @example config-sample.php * @global bool $translate_custom_enabled diff --git a/plugins/translate/functions.php b/plugins/translate/functions.php index 42c52c0e..f548be15 100644 --- a/plugins/translate/functions.php +++ b/plugins/translate/functions.php @@ -10,6 +10,14 @@ * @subpackage translate */ +/** + * Define for wrecked souls accessing functions script directly + * @ignore + */ +if (!defined('SM_PATH')) { + define('SM_PATH','../../'); +} + /** Load default config */ if (file_exists(SM_PATH . 'plugins/translate/config_default.php')) { include_once(SM_PATH . 'plugins/translate/config_default.php'); @@ -39,6 +47,8 @@ if (file_exists(SM_PATH . 'plugins/translate/config_default.php')) { $translate_gpltrans_enabled=true; global $translate_custom_enabled; $translate_custom_enabled=false; + // This is logged error message. Don't translate it. + error_log('SquirrelMail: default configuration file removed in translate plugin.'); } /** Load site config */ @@ -65,6 +75,7 @@ function translate_read_form_function() { $translate_dictionary_enabled, $translate_google_enabled, $translate_gpltrans_enabled, $translate_intertran_enabled, $translate_promt_enabled, $translate_otenet_enabled; + global $translate_custom_enabled; if (!$translate_show_read) { return; @@ -139,10 +150,7 @@ function translate_pref_function() { $translate_server = getPref($data_dir, $username, 'translate_server',$translate_default_engine); - $translate_location = getPref($data_dir, $username, 'translate_location'); - if ($translate_location == '') { - $translate_location = 'center'; - } + $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'); @@ -163,10 +171,61 @@ function translate_button_function() { } } +/** + * 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, @@ -190,7 +249,8 @@ function translate_showoption() { } /** - * + * Displays comments about available translation engines + * @access private */ function translate_showtrad() { global $translate_babelfish_enabled, $translate_go_enabled, @@ -200,8 +260,8 @@ function translate_showtrad() { global $translate_gpltrans_url, $translate_custom_enabled; if ($translate_babelfish_enabled) translate_showtrad_internal( 'Babelfish', - _("Maximum of 1000 characters translated, powered by Systran"). - '
'.sprintf(_("Number of supported language pairs: %s"),'19').' ' , + _("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"). @@ -229,7 +289,7 @@ function translate_showtrad() { '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"),'13').' ' , + '
'.sprintf(_("Number of supported language pairs: %s"),'16').' ' , 'http://www.online-translator.com/' ); if ($translate_custom_enabled && function_exists('translate_custom_showtrad')) { @@ -407,14 +467,22 @@ function translate_form_babelfish($message) { '; @@ -503,6 +593,7 @@ function translate_form_intertran($message) { translate_new_form('http://www.tranexp.com:2000/InterTran'); echo ''. ''. + ''. ''; $left = ''. - ''. + ''. '
\n"; echo "\n"; + echo _("Transliterate unknown words:") . '
'; echo 'PROMT: '; translate_table_end(); @@ -789,14 +887,13 @@ function translate_form_promt($message) { */ function translate_form_google($message) { translate_new_form('http://www.google.com/translate_t'); -?> - - - - - ' . + '' . + ''; + echo '' . + '' . ''. '
' . _("Select your translator:") . diff --git a/plugins/translate/setup.php b/plugins/translate/setup.php index a1419c97..b75a07dd 100644 --- a/plugins/translate/setup.php +++ b/plugins/translate/setup.php @@ -34,7 +34,9 @@ function squirrelmail_plugin_init_translate() { $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'; } /** @@ -74,4 +76,22 @@ function translate_pref() { include_once(SM_PATH . 'plugins/translate/functions.php'); translate_pref_function(); } + +/** + * Calls user's translation preferences saving function + * @access private + */ +function translate_save() { + include_once(SM_PATH . 'plugins/translate/functions.php'); + translate_save_function(); +} + +/** + * 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(); +} ?> \ No newline at end of file -- 2.25.1