phpdoc blocks and lowercasing html elements
[squirrelmail.git] / plugins / translate / setup.php
CommitLineData
849bdf42 1<?php
15e6162e 2/**
3 * setup.php
4 *
82d304a0 5 * Copyright (c) 1999-2004 The SquirrelMail Project Team
15e6162e 6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
87392775 8 * @version $Id$
ea5f4b8e 9 * @package plugins
10 * @subpackage translate
15e6162e 11 */
12
ea526024 13/*
14Easy plugin that sends the body of the message to a new browser
15window using the specified translator.
16
17Translation of composed messages is not supported.
849bdf42 18*/
19
20
ea5f4b8e 21/**
22 * Initialize the translation plugin
23 * @return void
87392775 24 * @access private
ea5f4b8e 25 */
849bdf42 26function squirrelmail_plugin_init_translate() {
27 global $squirrelmail_plugin_hooks;
28
29 $squirrelmail_plugin_hooks['read_body_bottom']['translate'] = 'translate_read_form';
cbe5423b 30 $squirrelmail_plugin_hooks['optpage_register_block']['translate'] = 'translate_optpage_register_block';
849bdf42 31 $squirrelmail_plugin_hooks['loading_prefs']['translate'] = 'translate_pref';
32 $squirrelmail_plugin_hooks['compose_button_row']['translate'] = 'translate_button';
33}
34
35
ea526024 36/**
37 * Shows translation box in message display window
87392775 38 * @access private
ea526024 39 */
849bdf42 40function translate_read_form() {
41 global $color, $translate_server;
03c13808 42 global $message, $translate_dir;
849bdf42 43 global $translate_show_read;
03c13808 44 global $imapConnection, $wrap_at, $passed_id, $mailbox;
849bdf42 45
46 if (!$translate_show_read) {
47 return;
48 }
49
50 $translate_dir = 'to';
03c13808 51
52$trans_ar = $message->findDisplayEntity(array(), array('text/plain'));
53$body = '';
54if ($trans_ar[0] != '') {
55 for ($i = 0; $i < count($trans_ar); $i++) {
56 $body .= formatBody($imapConnection, $message, $color, $wrap_at, $trans_ar[$i], $passed_id, $mailbox);
57 }
58 $hookResults = do_hook('message_body', $body);
59 $body = $hookResults[1];
60 } else {
61 $body = 'Message can\'t be translated';
62}
63
849bdf42 64 $new_body = $body;
65 $pos = strpos($new_body,
1ba8cd6b 66 '">'. _("Download this as a file") . '</A></CENTER><BR></SMALL>');
849bdf42 67 if (is_int($pos)) {
68 $new_body = substr($new_body, 0, $pos);
69 }
dec2dcf1 70
71 $trans = get_html_translation_table(HTML_ENTITIES);
849bdf42 72 $trans[' '] = '&nbsp;';
73 $trans = array_flip($trans);
74 $new_body = strtr($new_body, $trans);
75
76 $new_body = urldecode($new_body);
77 $new_body = strip_tags($new_body);
78
79 /* I really don't like this next part ... */
80 $new_body = str_replace('"', "''", $new_body);
81 $new_body = strtr($new_body, "\n", ' ');
82
83 $function = 'translate_form_' . $translate_server;
84 $function($new_body);
85}
86
ea526024 87/**
88 * Closes table tags in translation box
87392775 89 * @access private
ea526024 90 */
849bdf42 91function translate_table_end() {
92 ?></td>
93 </tr>
94 </table>
95 </td>
96 </tr>
97 </table>
98 </form>
99 <?php
100}
101
ea526024 102/**
87392775 103 * FIXME: Undocumented function.
104 * @access private
ea526024 105 */
849bdf42 106function translate_button() {
107 global $translate_show_send;
108
109 if (! $translate_show_send) {
110 return;
111 }
112}
113
ea526024 114/**
115 * Adds translation option block
87392775 116 * @access private
ea526024 117 */
cbe5423b 118function translate_optpage_register_block() {
119 global $optpage_blocks;
120 $optpage_blocks[] = array(
38a7b6a0 121 'name' => _("Translation Options"),
849bdf42 122 'url' => '../plugins/translate/options.php',
38a7b6a0 123 'desc' => _("Which translator should be used when you get messages in a different language?"),
849bdf42 124 'js' => false
125 );
126}
127
ea526024 128/**
129 * Gets user's translation preferences
87392775 130 * @access private
ea526024 131 */
849bdf42 132function translate_pref() {
133 global $username, $data_dir;
134 global $translate_server, $translate_location;
135 global $translate_show_send, $translate_show_read;
136 global $translate_same_window;
137
138 $translate_server = getPref($data_dir, $username, 'translate_server');
139 if ($translate_server == '') {
140 $translate_server = 'babelfish';
141 }
142
143 $translate_location = getPref($data_dir, $username, 'translate_location');
144 if ($translate_location == '') {
145 $translate_location = 'center';
146 }
147
148 $translate_show_send = getPref($data_dir, $username, 'translate_show_send');
149 $translate_show_read = getPref($data_dir, $username, 'translate_show_read');
150 $translate_same_window = getPref($data_dir, $username, 'translate_same_window');
151}
152
153
154/**
ea526024 155 * Tries to select default translation combination
ea526024 156 *
df7b27c1 157 * This function could be speed up.
849bdf42 158 * It basically negates the process if a ! is found in the beginning and
159 * matches a * at the end with 0 or more characters.
87392775 160 *
161 * @param string $test language code that has to be tested.
162 * @return boolean true if language code matches user's language.
163 * @access private
849bdf42 164 */
165function translate_does_it_match_language($test) {
166 global $squirrelmail_language;
167 $true = 1;
168 $false = 0;
169 $index = 0;
170 $smindex = 0;
171
172 if (! $test || ! $squirrelmail_language) {
173 return $false;
174 }
175
176 if ($test[$index] == '!') {
177 $index ++;
178 $true = 0;
179 $false = 1;
180 }
181
182 if (($index == 0) && ($test == $squirrelmail_language)) {
183 return $true;
184 }
185
008ca1ad 186 while (isset($test[$index]) && $test[$index]) {
849bdf42 187 if ($test[$index] == '*') {
188 return $true;
189 }
190 if ($test[$index] != $squirrelmail_language[$smindex]) {
191 return $false;
192 }
193 $index ++;
194 $smindex ++;
195 }
196
197 return $false;
198}
199
ea526024 200/**
201 * Creates language option selection box.
87392775 202 *
203 * @access private
ea526024 204 */
849bdf42 205function translate_lang_opt($from, $to, $value, $text) {
206 global $translate_dir;
38a7b6a0 207
208 $ret = ' <option value="' . $value . '"';
209
849bdf42 210 if (translate_does_it_match_language($to) && ($translate_dir == 'to')) {
38a7b6a0 211 $ret .= ' SELECTED';
849bdf42 212 }
213
214 if (translate_does_it_match_language($from) && ($translate_dir == 'from')) {
38a7b6a0 215 $ret .= ' SELECTED';
849bdf42 216 }
38a7b6a0 217
218 $ret .= '>' . $text . "</option>\n";
219
220 return( $ret );
849bdf42 221}
222
ea526024 223/**
224 * Starts translation box
225 *
226 * @param string $action url that has to recieve message for translation
87392775 227 * @access private
ea526024 228 */
849bdf42 229function translate_new_form($action) {
230 global $translate_dir, $translate_new_window, $translate_location;
231 global $color, $translate_same_window;
232
233 echo '<form action="';
234
235 if ($translate_dir == 'to') {
236 echo $action;
237 } else {
238 echo 'translate.php';
239 }
240
241 echo '" method="post"';
242
243 if (!$translate_same_window) {
244 echo ' target="_blank"';
245 }
38a7b6a0 246
849bdf42 247 echo ">\n";
248
249 ?><table align="<?php echo $translate_location ?>" cellpadding=3 cellspacing=0 border=0 bgcolor=<?php echo $color[10] ?>>
250 <tr>
251 <td>
252 <table cellpadding=2 cellspacing=1 border=0 bgcolor="<?php echo $color[5] ?>">
253 <tr>
254 <td><?php
255}
256
ea526024 257/**
258 * Babelfish translation engine functions
259 *
260 * @param string $message text that has to be translated.
87392775 261 * @access private
ea526024 262 */
849bdf42 263function translate_form_babelfish($message) {
03c13808 264 translate_new_form('http://babelfish.altavista.com/babelfish/tr');
849bdf42 265?>
266 <input type="hidden" name="doit" value="done">
03c13808 267 <input type="hidden" name="intl" value="1">
268 <input type="hidden" name="tt" value="urltext">
849bdf42 269 <input type="hidden" name="urltext" value="<?php echo $message; ?>">
270 <select name="lp"><?php
ea526024 271 echo translate_lang_opt('en_US', 'zh_CN', 'en_zh',
272 sprintf( _("%s to %s"),_("English"),_("Chinese"))) .
273 translate_lang_opt('en_US', 'fr_FR', 'en_fr',
274 sprintf( _("%s to %s"),_("English"),_("French"))) .
275 translate_lang_opt('en_US', 'de_DE', 'en_de',
276 sprintf( _("%s to %s"),_("English"),_("German"))) .
277 translate_lang_opt('en_US', 'it_IT', 'en_it',
278 sprintf( _("%s to %s"),_("English"),_("Italian"))) .
279 translate_lang_opt('en_US', 'ja_JP', 'en_ja',
280 sprintf( _("%s to %s"),_("English"),_("Japanese"))) .
281 translate_lang_opt('en_US', 'ko_KR', 'en_ko',
282 sprintf( _("%s to %s"),_("English"),_("Korean"))) .
283 translate_lang_opt('en_US', 'pt*', 'en_pt',
284 sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
285 translate_lang_opt('en_US', 'es_ES', 'en_es',
286 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
287 translate_lang_opt('zh_CN', '', 'zh_en',
288 sprintf( _("%s to %s"),_("Chinese"),_("English"))) .
289 translate_lang_opt('fr_FR', '', 'fr_en',
290 sprintf( _("%s to %s"),_("French"),_("English"))) .
291 translate_lang_opt('de_DE', 'en_US', 'de_en',
292 sprintf( _("%s to %s"),_("German"),_("English"))) .
293 translate_lang_opt('it_IT', '', 'it_en',
294 sprintf( _("%s to %s"),_("Italian"),_("English"))) .
295 translate_lang_opt('ja_JP', '', 'ja_en',
296 sprintf( _("%s to %s"),_("Japanese"),_("English"))) .
297 translate_lang_opt('ko_KR', '', 'ko_en',
298 sprintf( _("%s to %s"),_("Korean"),_("English"))) .
299 translate_lang_opt('pt*', '', 'pt_en',
300 sprintf( _("%s to %s"),_("Portuguese"),_("English"))) .
301 translate_lang_opt('es_ES', '', 'es_en',
302 sprintf( _("%s to %s"),_("Spanish"),_("English"))) .
303 translate_lang_opt('de_DE', '', 'de_fr',
304 sprintf( _("%s to %s"),_("German"),_("French"))) .
305 translate_lang_opt('fr_FR', '', 'fr_de',
306 sprintf( _("%s to %s"),_("French"),_("German"))) .
307 translate_lang_opt('ru_RU', '', 'ru_en',
308 sprintf( _("%s to %s"),_("Russian"),_("English")));
38a7b6a0 309 echo '</select>'.
310 'Babelfish: <input type="Submit" value="' . _("Translate") . '">';
311
849bdf42 312 translate_table_end();
313}
314
ea526024 315/**
316 * go.com translation engine (disabled)
317 *
318 * @param string $message text that has to be translated
87392775 319 * @access private
ea526024 320 */
849bdf42 321function translate_form_go($message) {
322 translate_new_form('http://translator.go.com/cb/trans_entry');
323?>
324 <input type=hidden name=input_type value=text>
325 <select name=lp><?php
ea526024 326 echo translate_lang_opt('en_US', 'es_ES', 'en_sp',
327 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
328 translate_lang_opt('en_US', 'fr_FR', 'en_fr',
329 sprintf( _("%s to %s"),_("English"),_("French"))) .
330 translate_lang_opt('en_US', 'de_DE', 'en_ge',
331 sprintf( _("%s to %s"),_("English"),_("German"))) .
332 translate_lang_opt('en_US', 'it_IT', 'en_it',
333 sprintf( _("%s to %s"),_("English"),_("Italian"))) .
334 translate_lang_opt('en_US', 'pt*', 'en_pt',
335 sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
336 translate_lang_opt('es_ES', '', 'sp_en',
337 sprintf( _("%s to %s"),_("Spanish"),_("English"))) .
338 translate_lang_opt('fr_FR', '', 'fr_en',
339 sprintf( _("%s to %s"),_("French"),_("English"))) .
340 translate_lang_opt('de_DE', 'en_US', 'ge_en',
341 sprintf( _("%s to %s"),_("German"),_("English"))) .
342 translate_lang_opt('it_IT', '', 'it_en',
343 sprintf( _("%s to %s"),_("Italian"),_("English"))) .
344 translate_lang_opt('pt*', '', 'pt_en',
345 sprintf( _("%s to %s"),_("Portuguese"),_("English")));
38a7b6a0 346 echo '</select>'.
347 "<input type=\"hidden\" name=\"text\" value=\"$message\">".
348 'Go.com: <input type="Submit" value="' . _("Translate") . '">';
349
849bdf42 350 translate_table_end();
351}
352
ea526024 353/**
354 * intertran translation engine
355 *
356 * @param string $message text that has to be translated
87392775 357 * @access private
ea526024 358 */
849bdf42 359function translate_form_intertran($message) {
360 translate_new_form('http://www.tranexp.com:2000/InterTran');
38a7b6a0 361 echo '<INPUT TYPE="hidden" NAME="topframe" VALUE="yes">'.
362 '<INPUT TYPE="hidden" NAME="type" VALUE="text">'.
363 "<input type=\"hidden\" name=\"text\" value=\"$message\">";
364
365 $left = '<SELECT name="from">' .
366 translate_lang_opt('pt_BR', '', 'pob', _("Brazilian Portuguese")).
ea526024 367 translate_lang_opt('bg_BG', '', 'bul', _("Bulgarian") . ' (CP 1251)').
368 translate_lang_opt('hr_HR', '', 'cro', _("Croatian") . ' (CP 1250)').
369 translate_lang_opt('cs_CZ', '', 'che', _("Czech") . ' (CP 1250)').
370 translate_lang_opt('da_DK', '', 'dan', _("Danish")).
371 translate_lang_opt('nl_NL', '', 'dut', _("Dutch")).
372 translate_lang_opt('en_US', '!en', 'eng', _("English")).
373 translate_lang_opt('tl_PH', '', 'tag', _("Filipino (Tagalog)")).
374 translate_lang_opt('fi_FI', '', 'fin', _("Finnish")).
375 translate_lang_opt('fr_FR', '', 'fre', _("French")).
df7b27c1 376 translate_lang_opt('de_DE', '', 'ger', _("German")).
ea526024 377 translate_lang_opt('el_GR', '', 'grk', _("Greek")).
378 translate_lang_opt('hu_HU', '', 'hun', _("Hungarian") . ' (CP 1250)').
379 translate_lang_opt('is_IS', '', 'ice', _("Icelandic")).
380 translate_lang_opt('it_IT', '', 'ita', _("Italian")).
381 translate_lang_opt('ja_JP', '', 'jpn', _("Japanese") . ' (Shift JIS)').
382 translate_lang_opt('la', '', 'ltt', _("Latin")).
383 translate_lang_opt('es*', '', 'spl', _("Latin American Spanish")).
38a7b6a0 384 translate_lang_opt('no*', '', 'nor', _("Norwegian")).
ea526024 385 translate_lang_opt('pl_PL', '', 'pol', _("Polish") . ' (ISO 8859-2)').
386 translate_lang_opt('pt*', '', 'poe', _("Portuguese")).
387 translate_lang_opt('ro_RO', '', 'rom', _("Romanian") . ' (CP 1250)').
388 translate_lang_opt('ru_RU', '', 'rus', _("Russian") . ' (CP 1251)').
389 translate_lang_opt('sr_YU', '', 'sel', _("Serbian") . ' (CP 1250)').
390 translate_lang_opt('sl_SI', '', 'slo', _("Slovenian") . ' (CP 1250)').
391 translate_lang_opt('es_ES', '', 'spa', _("Spanish")).
392 translate_lang_opt('sv_SE', '', 'swe', _("Swedish")).
393 translate_lang_opt('tr_TR', '', 'tur', _("Turkish") . ' (CP 1254)').
394 translate_lang_opt('cy_GB', '', 'wel', _("Welsh")).
38a7b6a0 395 '</SELECT>';
396
397 $right = '<SELECT name="to">'.
398 translate_lang_opt('', 'pt_BR', 'pob', _("Brazilian Portuguese")).
ea526024 399 translate_lang_opt('', 'bg_BG', 'bul', _("Bulgarian") . ' (CP 1251)').
400 translate_lang_opt('', 'hr_HR', 'cro', _("Croatian") . ' (CP 1250)').
401 translate_lang_opt('', 'cs_CZ', 'che', _("Czech") . ' (CP 1250)').
402 translate_lang_opt('', 'da_DK', 'dan', _("Danish")).
403 translate_lang_opt('', 'nl_NL', 'dut', _("Dutch")).
404 translate_lang_opt('!en', 'en_US', 'eng', _("English")).
405 translate_lang_opt('', 'tl_PH', 'tag', _("Filipino (Tagalog)")).
406 translate_lang_opt('', 'fi_FI', 'fin', _("Finnish")).
407 translate_lang_opt('', 'fr_FR', 'fre', _("French")).
408 translate_lang_opt('', 'de_DE', 'ger', _("German")).
409 translate_lang_opt('', 'el_GR', 'grk', _("Greek")).
410 translate_lang_opt('', 'hu_HU', 'hun', _("Hungarian") . ' (CP 1250)').
411 translate_lang_opt('', 'is_IS', 'ice', _("Icelandic")).
412 translate_lang_opt('', 'it_IT', 'ita', _("Italian")).
413 translate_lang_opt('', 'ja_JP', 'jpn', _("Japanese") . ' (Shift JIS)').
414 translate_lang_opt('', 'la', 'ltt', _("Latin")).
415 translate_lang_opt('', 'es*', 'spl', _("Latin American Spanish")).
38a7b6a0 416 translate_lang_opt('', 'no*', 'nor', _("Norwegian")).
ea526024 417 translate_lang_opt('', 'pl_PL', 'pol', _("Polish") . ' (ISO 8859-2)').
418 translate_lang_opt('', 'pt_PT', 'poe', _("Portuguese")).
419 translate_lang_opt('', 'ro_RO', 'rom', _("Romanian") . ' (CP 1250)').
420 translate_lang_opt('', 'ru_RU', 'rus', _("Russian") . ' (CP 1251)').
421 translate_lang_opt('', 'sr_YU', 'sel', _("Serbian") . ' (CP 1250)').
422 translate_lang_opt('', 'sl_SI', 'slo', _("Slovenian") . ' (CP 1250)').
423 translate_lang_opt('', 'es_ES', 'spa', _("Spanish")).
424 translate_lang_opt('', 'sv_SE', 'swe', _("Swedish")).
425 translate_lang_opt('', 'tr_TR', 'tur', _("Turkish") . ' (CP 1254)').
426 translate_lang_opt('', 'cy_GB', 'wel', _("Welsh")).
38a7b6a0 427 '</SELECT>';
428 printf( _("%s to %s"), $left, $right );
429 echo 'InterTran: <input type=submit value="' . _("Translate") . '">';
430
849bdf42 431 translate_table_end();
432}
433
ea526024 434/**
435 * gpltrans translation engine
436 *
437 * @param string $message text that has to be translated
87392775 438 * @access private
ea526024 439 */
849bdf42 440function translate_form_gpltrans($message) {
441 translate_new_form('http://www.translator.cx/cgi-bin/gplTrans');
03c13808 442 echo '<select name="language">'.
ea526024 443 translate_lang_opt('', 'nl_NL', 'dutch_dict', _("Dutch")).
444 translate_lang_opt('', 'fr_FR', 'french_dict', _("French")).
445 translate_lang_opt('', 'de_DE', 'german_dict', _("German")).
446 translate_lang_opt('', 'id_ID', 'indonesian_dict', _("Indonesian")).
447 translate_lang_opt('', 'it_IT', 'italian_dict', _("Italian")).
448 translate_lang_opt('', 'la', 'latin_dict', _("Latin")).
449 translate_lang_opt('', 'pt*', 'portuguese_dict', _("Portuguese")).
450 translate_lang_opt('', 'es_ES', 'spanish_dict', _("Spanish")).
03c13808 451 '</select>';
452 echo '<select name="toenglish">';
453 echo '<option value="yes" >'. _("to English") . '</option>';
454 echo '<option value="no" selected>' . _("from English") . '</option></select>';
455 echo "<input type=hidden name=text value=\"$message\">".
38a7b6a0 456 'GPLTrans: <input type="submit" value="' . _("Translate") . '">';
457
849bdf42 458 translate_table_end();
459}
460
ea526024 461/**
462 * reference.com (dictionary) translation engine
463 *
464 * @param string $message text that has to be translated
87392775 465 * @access private
ea526024 466 */
849bdf42 467function translate_form_dictionary($message) {
03c13808 468 translate_new_form('http://dictionary.reference.com/translate/text.html');
469 list($usec, $sec) = explode(" ",microtime());
470 $time = $sec . (float)$usec*100000000;
ea526024 471 echo "<input type=hidden name=text value=\"$message\" />".
472 "<input type=hidden name=r value=\"$time\" />".
38a7b6a0 473 '<SELECT NAME="lp">'.
ea526024 474 translate_lang_opt('en_US', 'zh_CN', 'en_zh',
475 sprintf( _("%s to %s"),_("English"),_("Simplified Chinese"))) .
476 translate_lang_opt('en_US', 'zh_TW', 'en_zt',
477 sprintf( _("%s to %s"),_("English"),_("Traditional Chinese"))) .
478 translate_lang_opt('en_US', 'nl_NL', 'en_nl',
479 sprintf( _("%s to %s"),_("English"),_("Dutch"))) .
480 translate_lang_opt('en_US', 'fr_FR', 'en_fr',
481 sprintf( _("%s to %s"),_("English"),_("French"))) .
482 translate_lang_opt('en_US', 'de_DE', 'en_ge',
483 sprintf( _("%s to %s"),_("English"),_("German"))) .
484 translate_lang_opt('en_US', 'el_GR', 'en_el',
485 sprintf( _("%s to %s"),_("English"),_("Greek"))) .
486 translate_lang_opt('en_US', 'it_IT', 'en_it',
487 sprintf( _("%s to %s"),_("English"),_("Italian"))) .
488 translate_lang_opt('en_US', 'ja_JP', 'en_ja',
489 sprintf( _("%s to %s"),_("English"),_("Japanese"))) .
490 translate_lang_opt('en_US', 'ko_KR', 'en_ko',
491 sprintf( _("%s to %s"),_("English"),_("Korean"))) .
492 translate_lang_opt('en_US', 'pt*', 'en_pt',
493 sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
494 translate_lang_opt('en_US', 'ru_RU', 'en_ru',
495 sprintf( _("%s to %s"),_("English"),_("Russian"))) .
496 translate_lang_opt('en_US', 'es_ES', 'en_es',
497 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
498 translate_lang_opt('zh_CN', '', 'zh_en',
499 sprintf( _("%s to %s"),_("Simplified Chinese"),_("English"))) .
500 translate_lang_opt('zh_TW', '', 'zt_en',
501 sprintf( _("%s to %s"),_("Traditional Chinese"),_("English"))) .
502 translate_lang_opt('nl_NL', '', 'nl_en',
503 sprintf( _("%s to %s"),_("Dutch"),_("English"))) .
504 translate_lang_opt('fr_FR', '', 'fr_en',
505 sprintf( _("%s to %s"),_("French"),_("English"))) .
506 translate_lang_opt('de_DE', 'en_US', 'ge_en',
507 sprintf( _("%s to %s"),_("German"),_("English"))) .
508 translate_lang_opt('el_GR', '', 'el_en',
509 sprintf( _("%s to %s"),_("Greek"),_("English"))) .
510 translate_lang_opt('it_IT', '', 'it_en',
511 sprintf( _("%s to %s"),_("Italian"),_("English"))) .
512 translate_lang_opt('ja_JP', '', 'ja_en',
513 sprintf( _("%s to %s"),_("Japanese"),_("English"))) .
514 translate_lang_opt('ko_KR', '', 'ko_en',
515 sprintf( _("%s to %s"),_("Korean"),_("English"))) .
516 translate_lang_opt('pt*', '', 'pt_en',
517 sprintf( _("%s to %s"),_("Portuguese"),_("English"))) .
518 translate_lang_opt('ru_RU', '', 'ru_en',
519 sprintf( _("%s to %s"),_("Russian"),_("English"))) .
520 translate_lang_opt('es_ES', '', 'es_en',
521 sprintf( _("%s to %s"),_("Spanish"),_("English"))) .
04f6008a 522 '</SELECT>'.
38a7b6a0 523 'Dictionary.com: <INPUT TYPE="submit" VALUE="'._("Translate").'">';
524
849bdf42 525 translate_table_end();
526}
702272dc 527
ea526024 528/**
529 * otenet translation engine
530 *
531 * @param string $message text that has to be translated
87392775 532 * @access private
ea526024 533 */
702272dc 534function translate_form_otenet($message) {
535 translate_new_form('http://systran.otenet.gr/cgi-bin/systran.cgi');
536?>
537 <input type="hidden" name="doit" value="done">
538 <INPUT NAME="partner" VALUE="OTEnet-en" type="hidden">
539 <input type="hidden" name="urltext" value="<?php echo $message; ?>">
540 <select name="lp" size="1"><?php
ea526024 541 echo translate_lang_opt('en_US', 'el_GR', 'en_el',
542 sprintf( _("%s to %s"),_("English"),_("Greek"))) .
543 translate_lang_opt('el_GR', 'en_US', 'el_en',
544 sprintf( _("%s to %s"),_("Greek"),_("English"))) .
545 translate_lang_opt('fr_FR', '', 'fr_el',
546 sprintf( _("%s to %s"),_("French"),_("Greek"))) .
547 translate_lang_opt('el_GR', 'fr_FR', 'el_fr',
548 sprintf( _("%s to %s"),_("Greek"),_("French"))) .
60b628ea 549 translate_lang_opt('#', '', '', "----------------") .
ea526024 550 translate_lang_opt('en_US', '', 'en_fr',
551 sprintf( _("%s to %s"),_("English"),_("French"))) .
552 translate_lang_opt('fr_FR', '', 'fr_en',
553 sprintf( _("%s to %s"),_("French"),_("English"))) .
554 translate_lang_opt('en_US', 'de_DE', 'en_de',
555 sprintf( _("%s to %s"),_("English"),_("German"))) .
556 translate_lang_opt('de_DE', '', 'de_en',
557 sprintf( _("%s to %s"),_("German"),_("English"))) .
558 translate_lang_opt('en_US', 'es_ES', 'en_es',
559 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
560 translate_lang_opt('es_ES', '', 'es_en',
561 sprintf( _("%s to %s"),_("Spanish"),_("English"))) .
562 translate_lang_opt('en_US', 'it_IT', 'en_it',
563 sprintf( _("%s to %s"),_("English"),_("Italian"))) .
564 translate_lang_opt('it_IT', '', 'it_en',
565 sprintf( _("%s to %s"),_("Italian"),_("English"))) .
566 translate_lang_opt('en_US', 'pt*', 'en_pt',
567 sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
568 translate_lang_opt('pt*', '', 'pt_en',
569 sprintf( _("%s to %s"),_("Portuguese"),_("English"))) .
570 translate_lang_opt('fr_FR', '', 'fr_de',
571 sprintf( _("%s to %s"),_("French"),_("German"))) .
572 translate_lang_opt('de_DE', '', 'de_fr',
573 sprintf( _("%s to %s"),_("German"),_("French"))) .
574 translate_lang_opt('fr_FR', '', 'fr_es',
575 sprintf( _("%s to %s"),_("French"),_("Spanish"))) .
576 translate_lang_opt('es_ES', '', 'es_fr',
577 sprintf( _("%s to %s"),_("Spanish"),_("French"))) .
578 translate_lang_opt('fr_FR', 'nl_NL', 'fr_nl',
579 sprintf( _("%s to %s"),_("French"),_("Dutch"))) .
580 translate_lang_opt('nl_NL', '', 'nl_fr',
581 sprintf( _("%s to %s"),_("Dutch"),_("French"))) ;
702272dc 582 echo '</select>'.
583 'OTEnet: <input type="Submit" value="' . _("Translate") . '">';
584 translate_table_end();
585
586}
b0abf4b1 587
ea526024 588/**
589 * promt translation engine
590 *
591 * @param string $message text that has to be translated
87392775 592 * @access private
ea526024 593 */
b0abf4b1 594function translate_form_promt($message) {
595 translate_new_form('http://www.translate.ru/text.asp#tr_form');
596 echo '<input type="hidden" name="status" value="translate">';
597 echo "<input type=\"hidden\" name=\"source\" value=\"$message\">";
598 echo _("Interface language")." : ";
599 echo "<select size=\"1\" name=\"lang\">\n";
600 echo "<option value=\"en\">" . _("English") . "</option>\n";
601 echo "<option value=\"ru\">" . _("Russian") . "</option>\n";
602 echo "<option value=\"de\">" . _("German") . "</option>\n";
603 echo "<option value=\"fr\">" . _("French") . "</option>\n";
604 echo "<option value=\"es\">" . _("Spanish") . "</option>\n";
605 echo "</select><br>\n";
606 echo _("Translation direction")." : ";
607 echo '<select size="1" id="direction" name="direction">';
ea526024 608 echo translate_lang_opt('en_US', 'ru_RU', 'er',
609 sprintf( _("%s to %s"),_("English"),_("Russian"))) .
610 translate_lang_opt('ru_RU', 'en_US', 're',
611 sprintf( _("%s to %s"),_("Russian"),_("English"))) .
612 translate_lang_opt('de_DE', '', 'gr',
613 sprintf( _("%s to %s"),_("German"),_("Russian"))) .
614 translate_lang_opt('ru_RU', 'de_DE', 'rg',
615 sprintf( _("%s to %s"),_("Russian"),_("German"))) .
616 translate_lang_opt('fr_FR', '', 'fr',
617 sprintf( _("%s to %s"),_("French"),_("Russian"))) .
618 translate_lang_opt('ru_RU', 'fr_FR', 'rf',
619 sprintf( _("%s to %s"),_("Russian"),_("French"))) .
620 translate_lang_opt('es_ES', '', 'sr',
621 sprintf( _("%s to %s"),_("Spanish"),_("Russian"))) .
622 translate_lang_opt('ru_RU', 'es_ES', 'rs',
623 sprintf( _("%s to %s"),_("Russian"),_("Spanish"))) .
624 translate_lang_opt('it_IT', '', 'ir',
625 sprintf( _("%s to %s"),_("Italian"),_("Russian"))) .
626 translate_lang_opt('en_US', '', 'eg',
627 sprintf( _("%s to %s"),_("English"),_("German"))) .
628 translate_lang_opt('de_DE', '', 'ge',
629 sprintf( _("%s to %s"),_("German"),_("English"))) .
630 translate_lang_opt('en_US', '', 'es',
631 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
632 translate_lang_opt('es_ES', '', 'se',
633 sprintf( _("%s to %s"),_("Spanish"),_("English"))) ;
b0abf4b1 634 echo "</select><br>\n";
635 echo "<input type=\"hidden\" name=\"template\" value=\"General\">\n";
636 echo 'PROMT: <input type="submit" value="' . _("Translate") . '">';
637
638 translate_table_end();
639}
640
ea526024 641/**
642 * google translation engine
643 *
644 * @param string $message text that has to be translated
87392775 645 * @access private
ea526024 646 */
df7b27c1 647function translate_form_google($message) {
648 translate_new_form('http://www.google.com/translate_t');
649?>
650 <input type="hidden" name="ie" value="Unknown">
651 <input type="hidden" name="oe" value="ASCII">
652 <input type="hidden" name="hl" value="en">
653 <input type="hidden" name="text" value="<?php echo $message; ?>">
654 <select name="langpair"><?php
655 echo translate_lang_opt('en_US', 'de_DE', 'en|de',
656 sprintf( _("%s to %s"),_("English"),_("German"))) .
657 translate_lang_opt('en_US', 'es_ES', 'en|es',
658 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
659 translate_lang_opt('en_US', 'fr_FR', 'en|fr',
660 sprintf( _("%s to %s"),_("English"),_("French"))) .
661 translate_lang_opt('en_US', 'it_IT', 'en|it',
662 sprintf( _("%s to %s"),_("English"),_("Italian"))) .
663 translate_lang_opt('en_US', 'pt*', 'en|pt',
664 sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
665 translate_lang_opt('de_DE', 'en_US', 'de|en',
666 sprintf( _("%s to %s"),_("German"),_("English"))) .
667 translate_lang_opt('de_DE', '', 'de|fr',
668 sprintf( _("%s to %s"),_("German"),_("French"))) .
669 translate_lang_opt('es_ES', '', 'es|en',
670 sprintf( _("%s to %s"),_("Spanish"),_("English"))) .
671 translate_lang_opt('fr_FR', '', 'fr|en',
672 sprintf( _("%s to %s"),_("French"),_("English"))) .
673 translate_lang_opt('fr_FR', '', 'fr|de',
674 sprintf( _("%s to %s"),_("French"),_("German"))) .
675 translate_lang_opt('it_IT', '', 'it|en',
676 sprintf( _("%s to %s"),_("Italian"),_("English"))) .
677 translate_lang_opt('pt*', '', 'pt|en',
678 sprintf( _("%s to %s"),_("Portuguese"),_("English")));
679 echo '</select>'.
680 'Google: <input type="Submit" value="' . _("Translate") . '">';
681
682 translate_table_end();
683}
684
87392775 685?>