dumping translate plugin changes into cvs.
[squirrelmail.git] / plugins / translate / functions.php
1 <?php
2 /**
3 * SquirrelMail translate plugin functions
4 *
5 * Copyright (c) 2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * @version $Id$
9 * @package plugins
10 * @subpackage translate
11 */
12
13 /** Load default config */
14 if (file_exists(SM_PATH . 'plugins/translate/config_default.php')) {
15 include_once(SM_PATH . 'plugins/translate/config_default.php');
16 } else {
17 /** Somebody removed default config */
18 global $translate_gpltrans_url;
19 $translate_gpltrans_url='';
20 global $disable_compose_translate;
21 $disable_compose_translate=true;
22 global $translate_default_engine;
23 $translate_default_engine='babelfish';
24 global $translate_babelfish_enabled;
25 $translate_babelfish_enabled=true;
26 global $translate_go_enabled;
27 $translate_go_enabled=false;
28 global $translate_dictionary_enabled;
29 $translate_dictionary_enabled=true;
30 global $translate_google_enabled;
31 $translate_google_enabled=true;
32 global $translate_intertran_enabled;
33 $translate_intertran_enabled=true;
34 global $translate_promt_enabled;
35 $translate_promt_enabled=true;
36 global $translate_otenet_enabled;
37 $translate_otenet_enabled=true;
38 global $translate_gpltrans_enabled;
39 $translate_gpltrans_enabled=true;
40 global $translate_custom_enabled;
41 $translate_custom_enabled=false;
42 }
43
44 /** Load site config */
45 if (file_exists(SM_PATH . 'config/translate_config.php')) {
46 include_once(SM_PATH . 'config/translate_config.php');
47 } elseif (file_exists(SM_PATH . 'plugins/translate/config.php')) {
48 include_once(SM_PATH . 'plugins/translate/config.php');
49 }
50
51 /** Setup functions */
52
53 /**
54 * Shows translation box in message display window
55 * @access private
56 */
57 function translate_read_form_function() {
58 global $color, $translate_server;
59 global $message, $translate_dir;
60 global $translate_show_read;
61 global $imapConnection, $wrap_at, $passed_id, $mailbox;
62 global $translate_gpltrans_url;
63
64 global $translate_babelfish_enabled, $translate_go_enabled,
65 $translate_dictionary_enabled, $translate_google_enabled,
66 $translate_gpltrans_enabled, $translate_intertran_enabled,
67 $translate_promt_enabled, $translate_otenet_enabled;
68
69 if (!$translate_show_read) {
70 return;
71 }
72
73 $translate_server_option='translate_' . $translate_server . '_enabled';
74 if ($translate_server=='gpltrans' && $translate_gpltrans_url=='' ||
75 ! $$translate_server_option || ! function_exists('translate_form_' . $translate_server)) {
76 error_box(_("Selected translation engine is disabled. Please update your translation preferences."),$color);
77 return;
78 }
79 $translate_dir = 'to';
80
81 $trans_ar = $message->findDisplayEntity(array(), array('text/plain'));
82 $body = '';
83 if ($trans_ar[0] != '') {
84 for ($i = 0; $i < count($trans_ar); $i++) {
85 $body .= formatBody($imapConnection, $message, $color, $wrap_at, $trans_ar[$i], $passed_id, $mailbox);
86 }
87 $hookResults = do_hook('message_body', $body);
88 $body = $hookResults[1];
89 } else {
90 $body = 'Message can\'t be translated';
91 }
92
93 $new_body = $body;
94 $pos = strpos($new_body,
95 '">'. _("Download this as a file") . '</a></center><br /></small>');
96 if (is_int($pos)) {
97 $new_body = substr($new_body, 0, $pos);
98 }
99
100 $trans = get_html_translation_table(HTML_ENTITIES);
101 $trans[' '] = '&nbsp;';
102 $trans = array_flip($trans);
103 $new_body = strtr($new_body, $trans);
104
105 $new_body = urldecode($new_body);
106 $new_body = strip_tags($new_body);
107
108 /* I really don't like this next part ... */
109 $new_body = str_replace('"', "''", $new_body);
110 $new_body = strtr($new_body, "\n", ' ');
111
112 $function = 'translate_form_' . $translate_server;
113 $function($new_body);
114 }
115
116 /**
117 * Adds translation option block
118 * @access private
119 */
120 function translate_optpage_function() {
121 global $optpage_blocks;
122 $optpage_blocks[] = array(
123 'name' => _("Translation Options"),
124 'url' => '../plugins/translate/options.php',
125 'desc' => _("Which translator should be used when you get messages in a different language?"),
126 'js' => false
127 );
128 }
129
130 /**
131 * Gets user's translation preferences
132 * @access private
133 */
134 function translate_pref_function() {
135 global $username, $data_dir;
136 global $translate_server, $translate_location;
137 global $translate_show_send, $translate_show_read;
138 global $translate_same_window,$translate_default_engine;
139
140 $translate_server = getPref($data_dir, $username, 'translate_server',$translate_default_engine);
141
142 $translate_location = getPref($data_dir, $username, 'translate_location');
143 if ($translate_location == '') {
144 $translate_location = 'center';
145 }
146
147 $translate_show_send = getPref($data_dir, $username, 'translate_show_send');
148 $translate_show_read = getPref($data_dir, $username, 'translate_show_read');
149 $translate_same_window = getPref($data_dir, $username, 'translate_same_window');
150 }
151
152 /**
153 * Should add translation options in compose window
154 *
155 * Unimplemented
156 * @access private
157 */
158 function translate_button_function() {
159 global $translate_show_send;
160
161 if (! $translate_show_send) {
162 return;
163 }
164 }
165
166 /** Option functions */
167
168 /**
169 *
170 */
171 function translate_showoption() {
172 global $translate_babelfish_enabled, $translate_go_enabled,
173 $translate_dictionary_enabled, $translate_google_enabled,
174 $translate_gpltrans_enabled, $translate_intertran_enabled,
175 $translate_promt_enabled, $translate_otenet_enabled;
176 global $translate_custom_enabled;
177
178 if ($translate_babelfish_enabled) translate_showoption_internal('server','babelfish', 'Babelfish');
179 if ($translate_go_enabled) translate_showoption_internal('server','go', 'Go.com');
180 if ($translate_dictionary_enabled) translate_showoption_internal('server','dictionary', 'Dictionary.com');
181 if ($translate_google_enabled) translate_showoption_internal('server','google', 'Google Translate');
182 if ($translate_gpltrans_enabled && $translate_gpltrans_url!='')
183 translate_showoption_internal('server','gpltrans', 'GPLTrans');
184 if ($translate_intertran_enabled) translate_showoption_internal('server','intertran', 'Intertran');
185 if ($translate_otenet_enabled) translate_showoption_internal('server','otenet', 'OTEnet');
186 if ($translate_promt_enabled) translate_showoption_internal('server','promt', 'PROMT');
187 if ($translate_custom_enabled && function_exists('translate_custom_showoption')) {
188 translate_custom_showoption();
189 }
190 }
191
192 /**
193 *
194 */
195 function translate_showtrad() {
196 global $translate_babelfish_enabled, $translate_go_enabled,
197 $translate_dictionary_enabled, $translate_google_enabled,
198 $translate_gpltrans_enabled, $translate_intertran_enabled,
199 $translate_promt_enabled, $translate_otenet_enabled;
200 global $translate_gpltrans_url, $translate_custom_enabled;
201
202 if ($translate_babelfish_enabled) translate_showtrad_internal( 'Babelfish',
203 _("Maximum of 1000 characters translated, powered by Systran").
204 "<br />".sprintf(_("Number of supported language pairs: %s"),"19")." " ,
205 'http://babelfish.altavista.com/' );
206 if ($translate_go_enabled) translate_showtrad_internal( 'Translator.Go.com',
207 _("Maximum of 25 kilobytes translated, powered by Systran").
208 "<br />".sprintf(_("Number of supported language pairs: %s"),"10")." " ,
209 'http://translator.go.com/' );
210 if ($translate_dictionary_enabled) translate_showtrad_internal( 'Dictionary.com',
211 _("No known limits, powered by Systran").
212 "<br />".sprintf(_("Number of supported language pairs: %s"),"24")." " ,
213 'http://www.dictionary.com/translate' );
214 if ($translate_google_enabled) translate_showtrad_internal( 'Google Translate',
215 _("No known limits, powered by Systran").
216 "<br />".sprintf(_("Number of supported language pairs: %s"),"12")." " ,
217 'http://www.google.com/translate' );
218 if ($translate_gpltrans_enabled && $translate_gpltrans_url!='') translate_showtrad_internal( 'GPLTrans',
219 _("No known limits, powered by GPLTrans (free, open source)").
220 "<br />".sprintf(_("Number of supported language pairs: %s"),"16")." " ,
221 'http://www.translator.cx/' );
222 if ($translate_intertran_enabled) translate_showtrad_internal( 'InterTran',
223 _("No known limits, powered by Translation Experts' InterTran").
224 "<br />".sprintf(_("Number of supported languages: %s"),"29")." " ,
225 'http://www.tranexp.com/' );
226 if ($translate_otenet_enabled) translate_showtrad_internal( 'OTEnet',
227 _("Hellenic translations, no known limits, powered by Systran").
228 "<br />".sprintf(_("Number of supported language pairs: %s"),"20")." " ,
229 'http://systran.otenet.gr/' );
230 if ($translate_promt_enabled) translate_showtrad_internal( 'PROMT',
231 _("Russian translations, maximum of 500 characters translated").
232 "<br />".sprintf(_("Number of supported language pairs: %s"),"13")." " ,
233 'http://www.online-translator.com/' );
234
235 if ($translate_custom_enabled && function_exists('translate_custom_showtrad')) {
236 translate_custom_showtrad();
237 }
238 }
239
240 /**
241 * Creates options for translation selection boxes
242 * @param string $Var option type (server,location)
243 * @param string $value option value
244 * @param string $Desc description of translation server
245 * @access private
246 * @since 1.5.1
247 */
248 function translate_showoption_internal($Var,$value, $Desc) {
249 $Var='translate_' . $Var;
250
251 global $$Var;
252
253 echo '<option value="' . $value . '"';
254 if ($$Var == $value) {
255 echo ' selected="selected"';
256 }
257 echo '>' . $Desc . "</option>\n";
258 }
259
260 /**
261 * Creates translation server description
262 * @param string $tit title
263 * @param string $com comments about translation server
264 * @param string $url url of translation server
265 * @access private
266 */
267 function translate_showtrad_internal( $tit, $com, $url ) {
268 echo "<li><b>$tit</b> - ".
269 $com .
270 "[ <a href=\"$url\" target=\"_blank\">$tit</a> ]</li>";
271 }
272
273 /** Internal functions */
274
275 /**
276 * Closes table tags in translation box
277 * @access private
278 */
279 function translate_table_end() {
280 ?></td>
281 </tr>
282 </table>
283 </td>
284 </tr>
285 </table>
286 </form>
287 <?php
288 }
289
290 /**
291 * Tries to select default translation combination
292 *
293 * This function could be speed up.
294 * It basically negates the process if a ! is found in the beginning and
295 * matches a * at the end with 0 or more characters.
296 *
297 * @param string $test language code that has to be tested.
298 * @return boolean true if language code matches user's language.
299 * @access private
300 */
301 function translate_does_it_match_language($test) {
302 global $squirrelmail_language;
303 $true = 1;
304 $false = 0;
305 $index = 0;
306 $smindex = 0;
307
308 if (! $test || ! $squirrelmail_language) {
309 return $false;
310 }
311
312 if ($test[$index] == '!') {
313 $index ++;
314 $true = 0;
315 $false = 1;
316 }
317
318 if (($index == 0) && ($test == $squirrelmail_language)) {
319 return $true;
320 }
321
322 while (isset($test[$index]) && $test[$index]) {
323 if ($test[$index] == '*') {
324 return $true;
325 }
326 if ($test[$index] != $squirrelmail_language[$smindex]) {
327 return $false;
328 }
329 $index ++;
330 $smindex ++;
331 }
332
333 return $false;
334 }
335
336 /**
337 * Creates language option selection box.
338 * @param string $from
339 * @param string $to
340 * @param string $value
341 * @param string $text
342 * @access private
343 */
344 function translate_lang_opt($from, $to, $value, $text) {
345 global $translate_dir;
346
347 $ret = ' <option value="' . $value . '"';
348
349 if (translate_does_it_match_language($to) && ($translate_dir == 'to')) {
350 $ret .= ' selected="selected"';
351 }
352
353 if (translate_does_it_match_language($from) && ($translate_dir == 'from')) {
354 $ret .= ' selected="selected"';
355 }
356
357 $ret .= '>' . $text . "</option>\n";
358
359 return( $ret );
360 }
361
362 /**
363 * Starts translation box
364 *
365 * @param string $action url that has to recieve message for translation
366 * @access private
367 */
368 function translate_new_form($action) {
369 global $translate_dir, $translate_new_window, $translate_location;
370 global $color, $translate_same_window;
371
372 echo '<form action="';
373
374 if ($translate_dir == 'to') {
375 echo $action;
376 } else {
377 echo 'translate.php';
378 }
379
380 echo '" method="post"';
381
382 if (!$translate_same_window) {
383 echo ' target="_blank"';
384 }
385
386 echo ">\n";
387
388 ?><table align="<?php echo $translate_location ?>" cellpadding=3 cellspacing=0 border=0 bgcolor=<?php echo $color[10] ?>>
389 <tr>
390 <td>
391 <table cellpadding=2 cellspacing=1 border=0 bgcolor="<?php echo $color[5] ?>">
392 <tr>
393 <td><?php
394 }
395
396 /**
397 * Babelfish translation engine functions
398 *
399 * @param string $message text that has to be translated.
400 * @access private
401 */
402 function translate_form_babelfish($message) {
403 translate_new_form('http://babelfish.altavista.com/babelfish/tr');
404 ?>
405 <input type="hidden" name="doit" value="done" />
406 <input type="hidden" name="intl" value="1" />
407 <input type="hidden" name="tt" value="urltext" />
408 <input type="hidden" name="trtext" value="<?php echo $message; ?>" />
409 <select name="lp"><?php
410 echo translate_lang_opt('en_US', 'zh_CN', 'en_zh',
411 sprintf( _("%s to %s"),_("English"),_("Chinese Simplified"))) .
412 translate_lang_opt('en_US', 'zh_TW', 'en_zt',
413 sprintf( _("%s to %s"),_("English"),_("Chinese Traditional"))) .
414 translate_lang_opt('en_US', 'fr_FR', 'en_fr',
415 sprintf( _("%s to %s"),_("English"),_("French"))) .
416 translate_lang_opt('en_US', 'de_DE', 'en_de',
417 sprintf( _("%s to %s"),_("English"),_("German"))) .
418 translate_lang_opt('en_US', 'it_IT', 'en_it',
419 sprintf( _("%s to %s"),_("English"),_("Italian"))) .
420 translate_lang_opt('en_US', 'ja_JP', 'en_ja',
421 sprintf( _("%s to %s"),_("English"),_("Japanese"))) .
422 translate_lang_opt('en_US', 'ko_KR', 'en_ko',
423 sprintf( _("%s to %s"),_("English"),_("Korean"))) .
424 translate_lang_opt('en_US', 'pt*', 'en_pt',
425 sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
426 translate_lang_opt('en_US', 'es_ES', 'en_es',
427 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
428 translate_lang_opt('zh_CN', '', 'zh_en',
429 sprintf( _("%s to %s"),_("Chinese Simplified"),_("English"))) .
430 translate_lang_opt('zh_TW', '', 'zt_en',
431 sprintf( _("%s to %s"),_("Chinese Traditional"),_("English"))) .
432 translate_lang_opt('fr_FR', '', 'fr_en',
433 sprintf( _("%s to %s"),_("French"),_("English"))) .
434 translate_lang_opt('de_DE', 'en_US', 'de_en',
435 sprintf( _("%s to %s"),_("German"),_("English"))) .
436 translate_lang_opt('it_IT', '', 'it_en',
437 sprintf( _("%s to %s"),_("Italian"),_("English"))) .
438 translate_lang_opt('ja_JP', '', 'ja_en',
439 sprintf( _("%s to %s"),_("Japanese"),_("English"))) .
440 translate_lang_opt('ko_KR', '', 'ko_en',
441 sprintf( _("%s to %s"),_("Korean"),_("English"))) .
442 translate_lang_opt('pt*', '', 'pt_en',
443 sprintf( _("%s to %s"),_("Portuguese"),_("English"))) .
444 translate_lang_opt('es_ES', '', 'es_en',
445 sprintf( _("%s to %s"),_("Spanish"),_("English"))) .
446 translate_lang_opt('de_DE', '', 'de_fr',
447 sprintf( _("%s to %s"),_("German"),_("French"))) .
448 translate_lang_opt('fr_FR', '', 'fr_de',
449 sprintf( _("%s to %s"),_("French"),_("German"))) .
450 translate_lang_opt('ru_RU', '', 'ru_en',
451 sprintf( _("%s to %s"),_("Russian"),_("English")));
452 echo '</select>'.
453 'Babelfish: <input type="submit" value="' . _("Translate") . '" />';
454
455 translate_table_end();
456 }
457
458 /**
459 * go.com translation engine (disabled)
460 *
461 * @param string $message text that has to be translated
462 * @access private
463 */
464 function translate_form_go($message) {
465 translate_new_form('http://translator.go.com/cb/trans_entry');
466 ?>
467 <input type="hidden" name="input_type" value="text" />
468 <select name="lp"><?php
469 echo translate_lang_opt('en_US', 'es_ES', 'en_sp',
470 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
471 translate_lang_opt('en_US', 'fr_FR', 'en_fr',
472 sprintf( _("%s to %s"),_("English"),_("French"))) .
473 translate_lang_opt('en_US', 'de_DE', 'en_ge',
474 sprintf( _("%s to %s"),_("English"),_("German"))) .
475 translate_lang_opt('en_US', 'it_IT', 'en_it',
476 sprintf( _("%s to %s"),_("English"),_("Italian"))) .
477 translate_lang_opt('en_US', 'pt*', 'en_pt',
478 sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
479 translate_lang_opt('es_ES', '', 'sp_en',
480 sprintf( _("%s to %s"),_("Spanish"),_("English"))) .
481 translate_lang_opt('fr_FR', '', 'fr_en',
482 sprintf( _("%s to %s"),_("French"),_("English"))) .
483 translate_lang_opt('de_DE', 'en_US', 'ge_en',
484 sprintf( _("%s to %s"),_("German"),_("English"))) .
485 translate_lang_opt('it_IT', '', 'it_en',
486 sprintf( _("%s to %s"),_("Italian"),_("English"))) .
487 translate_lang_opt('pt*', '', 'pt_en',
488 sprintf( _("%s to %s"),_("Portuguese"),_("English")));
489 echo '</select>'.
490 '<input type="hidden" name="text" value="'.$message.'" />'.
491 'Go.com: <input type="submit" value="' . _("Translate") . '" />';
492
493 translate_table_end();
494 }
495
496 /**
497 * intertran translation engine
498 *
499 * @param string $message text that has to be translated
500 * @access private
501 */
502 function translate_form_intertran($message) {
503 translate_new_form('http://www.tranexp.com:2000/InterTran');
504 echo '<input type="hidden" name="topframe" value="yes" />'.
505 '<input type="hidden" name="type" value="text" />'.
506 '<input type="hidden" name="text" value="'.$message.'" />';
507
508 $left = '<select name="from">' .
509 translate_lang_opt('pt_BR', '', 'pob', _("Brazilian Portuguese")).
510 translate_lang_opt('bg_BG', '', 'bul', _("Bulgarian") . ' (CP 1251)').
511 translate_lang_opt('hr_HR', '', 'cro', _("Croatian") . ' (CP 1250)').
512 translate_lang_opt('cs_CZ', '', 'che', _("Czech") . ' (CP 1250)').
513 translate_lang_opt('da_DK', '', 'dan', _("Danish")).
514 translate_lang_opt('nl_NL', '', 'dut', _("Dutch")).
515 translate_lang_opt('en_US', '!en', 'eng', _("English")).
516 translate_lang_opt('tl_PH', '', 'tag', _("Filipino (Tagalog)")).
517 translate_lang_opt('fi_FI', '', 'fin', _("Finnish")).
518 translate_lang_opt('fr_FR', '', 'fre', _("French")).
519 translate_lang_opt('de_DE', '', 'ger', _("German")).
520 translate_lang_opt('el_GR', '', 'grk', _("Greek")).
521 translate_lang_opt('hu_HU', '', 'hun', _("Hungarian") . ' (CP 1250)').
522 translate_lang_opt('is_IS', '', 'ice', _("Icelandic")).
523 translate_lang_opt('it_IT', '', 'ita', _("Italian")).
524 translate_lang_opt('ja_JP', '', 'jpn', _("Japanese") . ' (Shift JIS)').
525 translate_lang_opt('la', '', 'ltt', _("Latin")).
526 translate_lang_opt('es*', '', 'spl', _("Latin American Spanish")).
527 translate_lang_opt('no*', '', 'nor', _("Norwegian")).
528 translate_lang_opt('pl_PL', '', 'pol', _("Polish") . ' (ISO 8859-2)').
529 translate_lang_opt('pt*', '', 'poe', _("Portuguese")).
530 translate_lang_opt('ro_RO', '', 'rom', _("Romanian") . ' (CP 1250)').
531 translate_lang_opt('ru_RU', '', 'rus', _("Russian") . ' (CP 1251)').
532 translate_lang_opt('sr_YU', '', 'sel', _("Serbian") . ' (CP 1250)').
533 translate_lang_opt('sl_SI', '', 'slo', _("Slovenian") . ' (CP 1250)').
534 translate_lang_opt('es_ES', '', 'spa', _("Spanish")).
535 translate_lang_opt('sv_SE', '', 'swe', _("Swedish")).
536 translate_lang_opt('tr_TR', '', 'tur', _("Turkish") . ' (CP 1254)').
537 translate_lang_opt('cy_GB', '', 'wel', _("Welsh")).
538 '</select>';
539
540 $right = '<select name="to">'.
541 translate_lang_opt('', 'pt_BR', 'pob', _("Brazilian Portuguese")).
542 translate_lang_opt('', 'bg_BG', 'bul', _("Bulgarian") . ' (CP 1251)').
543 translate_lang_opt('', 'hr_HR', 'cro', _("Croatian") . ' (CP 1250)').
544 translate_lang_opt('', 'cs_CZ', 'che', _("Czech") . ' (CP 1250)').
545 translate_lang_opt('', 'da_DK', 'dan', _("Danish")).
546 translate_lang_opt('', 'nl_NL', 'dut', _("Dutch")).
547 translate_lang_opt('!en', 'en_US', 'eng', _("English")).
548 translate_lang_opt('', 'tl_PH', 'tag', _("Filipino (Tagalog)")).
549 translate_lang_opt('', 'fi_FI', 'fin', _("Finnish")).
550 translate_lang_opt('', 'fr_FR', 'fre', _("French")).
551 translate_lang_opt('', 'de_DE', 'ger', _("German")).
552 translate_lang_opt('', 'el_GR', 'grk', _("Greek")).
553 translate_lang_opt('', 'hu_HU', 'hun', _("Hungarian") . ' (CP 1250)').
554 translate_lang_opt('', 'is_IS', 'ice', _("Icelandic")).
555 translate_lang_opt('', 'it_IT', 'ita', _("Italian")).
556 translate_lang_opt('', 'ja_JP', 'jpn', _("Japanese") . ' (Shift JIS)').
557 translate_lang_opt('', 'la', 'ltt', _("Latin")).
558 translate_lang_opt('', 'es*', 'spl', _("Latin American Spanish")).
559 translate_lang_opt('', 'no*', 'nor', _("Norwegian")).
560 translate_lang_opt('', 'pl_PL', 'pol', _("Polish") . ' (ISO 8859-2)').
561 translate_lang_opt('', 'pt_PT', 'poe', _("Portuguese")).
562 translate_lang_opt('', 'ro_RO', 'rom', _("Romanian") . ' (CP 1250)').
563 translate_lang_opt('', 'ru_RU', 'rus', _("Russian") . ' (CP 1251)').
564 translate_lang_opt('', 'sr_YU', 'sel', _("Serbian") . ' (CP 1250)').
565 translate_lang_opt('', 'sl_SI', 'slo', _("Slovenian") . ' (CP 1250)').
566 translate_lang_opt('', 'es_ES', 'spa', _("Spanish")).
567 translate_lang_opt('', 'sv_SE', 'swe', _("Swedish")).
568 translate_lang_opt('', 'tr_TR', 'tur', _("Turkish") . ' (CP 1254)').
569 translate_lang_opt('', 'cy_GB', 'wel', _("Welsh")).
570 '</select>';
571 printf( _("%s to %s"), $left, $right );
572 echo 'InterTran: <input type="submit" value="' . _("Translate") . '" />';
573
574 translate_table_end();
575 }
576
577 /**
578 * gpltrans translation engine
579 *
580 * @param string $message text that has to be translated
581 * @access private
582 */
583 function translate_form_gpltrans($message) {
584 translate_new_form('http://www.translator.cx/cgi-bin/gplTrans');
585 echo '<select name="language">'.
586 translate_lang_opt('', 'nl_NL', 'dutch_dict', _("Dutch")).
587 translate_lang_opt('', 'fr_FR', 'french_dict', _("French")).
588 translate_lang_opt('', 'de_DE', 'german_dict', _("German")).
589 translate_lang_opt('', 'id_ID', 'indonesian_dict', _("Indonesian")).
590 translate_lang_opt('', 'it_IT', 'italian_dict', _("Italian")).
591 translate_lang_opt('', 'la', 'latin_dict', _("Latin")).
592 translate_lang_opt('', 'pt*', 'portuguese_dict', _("Portuguese")).
593 translate_lang_opt('', 'es_ES', 'spanish_dict', _("Spanish")).
594 '</select>';
595 echo '<select name="toenglish">';
596 echo '<option value="yes">'. _("to English") . '</option>';
597 echo '<option value="no" selected="selected">' . _("from English") . '</option></select>';
598 echo '<input type="hidden" name="text" value="'.$message.'" />'.
599 'GPLTrans: <input type="submit" value="' . _("Translate") . '" />';
600
601 translate_table_end();
602 }
603
604 /**
605 * reference.com (dictionary) translation engine
606 *
607 * @param string $message text that has to be translated
608 * @access private
609 */
610 function translate_form_dictionary($message) {
611 translate_new_form('http://dictionary.reference.com/translate/text.html');
612 list($usec, $sec) = explode(" ",microtime());
613 $time = $sec . (float)$usec*100000000;
614 echo '<input type="hidden" name="text" value="'.$message.'" />'.
615 '<input type="hidden" name="r" value="'.$time.'" />'.
616 '<select name="lp">'.
617 translate_lang_opt('en_US', 'zh_CN', 'en_zh',
618 sprintf( _("%s to %s"),_("English"),_("Simplified Chinese"))) .
619 translate_lang_opt('en_US', 'zh_TW', 'en_zt',
620 sprintf( _("%s to %s"),_("English"),_("Traditional Chinese"))) .
621 translate_lang_opt('en_US', 'nl_NL', 'en_nl',
622 sprintf( _("%s to %s"),_("English"),_("Dutch"))) .
623 translate_lang_opt('en_US', 'fr_FR', 'en_fr',
624 sprintf( _("%s to %s"),_("English"),_("French"))) .
625 translate_lang_opt('en_US', 'de_DE', 'en_ge',
626 sprintf( _("%s to %s"),_("English"),_("German"))) .
627 translate_lang_opt('en_US', 'el_GR', 'en_el',
628 sprintf( _("%s to %s"),_("English"),_("Greek"))) .
629 translate_lang_opt('en_US', 'it_IT', 'en_it',
630 sprintf( _("%s to %s"),_("English"),_("Italian"))) .
631 translate_lang_opt('en_US', 'ja_JP', 'en_ja',
632 sprintf( _("%s to %s"),_("English"),_("Japanese"))) .
633 translate_lang_opt('en_US', 'ko_KR', 'en_ko',
634 sprintf( _("%s to %s"),_("English"),_("Korean"))) .
635 translate_lang_opt('en_US', 'pt*', 'en_pt',
636 sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
637 translate_lang_opt('en_US', 'ru_RU', 'en_ru',
638 sprintf( _("%s to %s"),_("English"),_("Russian"))) .
639 translate_lang_opt('en_US', 'es_ES', 'en_es',
640 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
641 translate_lang_opt('zh_CN', '', 'zh_en',
642 sprintf( _("%s to %s"),_("Simplified Chinese"),_("English"))) .
643 translate_lang_opt('zh_TW', '', 'zt_en',
644 sprintf( _("%s to %s"),_("Traditional Chinese"),_("English"))) .
645 translate_lang_opt('nl_NL', '', 'nl_en',
646 sprintf( _("%s to %s"),_("Dutch"),_("English"))) .
647 translate_lang_opt('fr_FR', '', 'fr_en',
648 sprintf( _("%s to %s"),_("French"),_("English"))) .
649 translate_lang_opt('de_DE', 'en_US', 'ge_en',
650 sprintf( _("%s to %s"),_("German"),_("English"))) .
651 translate_lang_opt('el_GR', '', 'el_en',
652 sprintf( _("%s to %s"),_("Greek"),_("English"))) .
653 translate_lang_opt('it_IT', '', 'it_en',
654 sprintf( _("%s to %s"),_("Italian"),_("English"))) .
655 translate_lang_opt('ja_JP', '', 'ja_en',
656 sprintf( _("%s to %s"),_("Japanese"),_("English"))) .
657 translate_lang_opt('ko_KR', '', 'ko_en',
658 sprintf( _("%s to %s"),_("Korean"),_("English"))) .
659 translate_lang_opt('pt*', '', 'pt_en',
660 sprintf( _("%s to %s"),_("Portuguese"),_("English"))) .
661 translate_lang_opt('ru_RU', '', 'ru_en',
662 sprintf( _("%s to %s"),_("Russian"),_("English"))) .
663 translate_lang_opt('es_ES', '', 'es_en',
664 sprintf( _("%s to %s"),_("Spanish"),_("English"))) .
665 '</select>'.
666 'Dictionary.com: <input type="submit" value="'._("Translate").'" />';
667
668 translate_table_end();
669 }
670
671 /**
672 * otenet translation engine
673 *
674 * @param string $message text that has to be translated
675 * @access private
676 */
677 function translate_form_otenet($message) {
678 translate_new_form('http://systran.otenet.gr/cgi-bin/systran.cgi');
679 ?>
680 <input type="hidden" name="doit" value="done" />
681 <input type="hidden" name="partner" value="OTEnet-en" />
682 <input type="hidden" name="urltext" value="<?php echo $message; ?>" />
683 <select name="lp" size="1"><?php
684 echo translate_lang_opt('en_US', 'el_GR', 'en_el',
685 sprintf( _("%s to %s"),_("English"),_("Greek"))) .
686 translate_lang_opt('el_GR', 'en_US', 'el_en',
687 sprintf( _("%s to %s"),_("Greek"),_("English"))) .
688 translate_lang_opt('fr_FR', '', 'fr_el',
689 sprintf( _("%s to %s"),_("French"),_("Greek"))) .
690 translate_lang_opt('el_GR', 'fr_FR', 'el_fr',
691 sprintf( _("%s to %s"),_("Greek"),_("French"))) .
692 translate_lang_opt('#', '', '', '----------------') .
693 translate_lang_opt('en_US', '', 'en_fr',
694 sprintf( _("%s to %s"),_("English"),_("French"))) .
695 translate_lang_opt('fr_FR', '', 'fr_en',
696 sprintf( _("%s to %s"),_("French"),_("English"))) .
697 translate_lang_opt('en_US', 'de_DE', 'en_de',
698 sprintf( _("%s to %s"),_("English"),_("German"))) .
699 translate_lang_opt('de_DE', '', 'de_en',
700 sprintf( _("%s to %s"),_("German"),_("English"))) .
701 translate_lang_opt('en_US', 'es_ES', 'en_es',
702 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
703 translate_lang_opt('es_ES', '', 'es_en',
704 sprintf( _("%s to %s"),_("Spanish"),_("English"))) .
705 translate_lang_opt('en_US', 'it_IT', 'en_it',
706 sprintf( _("%s to %s"),_("English"),_("Italian"))) .
707 translate_lang_opt('it_IT', '', 'it_en',
708 sprintf( _("%s to %s"),_("Italian"),_("English"))) .
709 translate_lang_opt('en_US', 'pt*', 'en_pt',
710 sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
711 translate_lang_opt('pt*', '', 'pt_en',
712 sprintf( _("%s to %s"),_("Portuguese"),_("English"))) .
713 translate_lang_opt('fr_FR', '', 'fr_de',
714 sprintf( _("%s to %s"),_("French"),_("German"))) .
715 translate_lang_opt('de_DE', '', 'de_fr',
716 sprintf( _("%s to %s"),_("German"),_("French"))) .
717 translate_lang_opt('fr_FR', '', 'fr_es',
718 sprintf( _("%s to %s"),_("French"),_("Spanish"))) .
719 translate_lang_opt('es_ES', '', 'es_fr',
720 sprintf( _("%s to %s"),_("Spanish"),_("French"))) .
721 translate_lang_opt('fr_FR', 'nl_NL', 'fr_nl',
722 sprintf( _("%s to %s"),_("French"),_("Dutch"))) .
723 translate_lang_opt('nl_NL', '', 'nl_fr',
724 sprintf( _("%s to %s"),_("Dutch"),_("French"))) ;
725 echo '</select>'.
726 'OTEnet: <input type="submit" value="' . _("Translate") . '" />';
727
728 translate_table_end();
729 }
730
731 /**
732 * promt translation engine
733 *
734 * @param string $message text that has to be translated
735 * @access private
736 */
737 function translate_form_promt($message) {
738 translate_new_form('http://www.online-translator.com/text.asp#tr_form');
739 echo '<input type="hidden" name="status" value="translate" />';
740 echo '<input type="hidden" name="source" value="'.$message.'" />';
741 echo _("Interface language")." : ";
742 echo "<select size=\"1\" name=\"lang\">\n";
743 echo '<option value="en">' . _("English") . "</option>\n";
744 echo '<option value="ru">' . _("Russian") . "</option>\n";
745 echo '<option value="de">' . _("German") . "</option>\n";
746 echo '<option value="fr">' . _("French") . "</option>\n";
747 echo '<option value="es">' . _("Spanish") . "</option>\n";
748 echo "</select><br />\n";
749 echo _("Translation direction")." : ";
750 echo '<select size="1" id="direction" name="direction">';
751 echo translate_lang_opt('en_US', 'ru_RU', 'er',
752 sprintf( _("%s to %s"),_("English"),_("Russian"))) .
753 translate_lang_opt('ru_RU', 'en_US', 're',
754 sprintf( _("%s to %s"),_("Russian"),_("English"))) .
755 translate_lang_opt('de_DE', '', 'gr',
756 sprintf( _("%s to %s"),_("German"),_("Russian"))) .
757 translate_lang_opt('ru_RU', 'de_DE', 'rg',
758 sprintf( _("%s to %s"),_("Russian"),_("German"))) .
759 translate_lang_opt('fr_FR', '', 'fr',
760 sprintf( _("%s to %s"),_("French"),_("Russian"))) .
761 translate_lang_opt('ru_RU', 'fr_FR', 'rf',
762 sprintf( _("%s to %s"),_("Russian"),_("French"))) .
763 translate_lang_opt('es_ES', '', 'sr',
764 sprintf( _("%s to %s"),_("Spanish"),_("Russian"))) .
765 translate_lang_opt('ru_RU', 'es_ES', 'rs',
766 sprintf( _("%s to %s"),_("Russian"),_("Spanish"))) .
767 translate_lang_opt('it_IT', '', 'ir',
768 sprintf( _("%s to %s"),_("Italian"),_("Russian"))) .
769 translate_lang_opt('en_US', '', 'eg',
770 sprintf( _("%s to %s"),_("English"),_("German"))) .
771 translate_lang_opt('de_DE', '', 'ge',
772 sprintf( _("%s to %s"),_("German"),_("English"))) .
773 translate_lang_opt('en_US', '', 'es',
774 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
775 translate_lang_opt('es_ES', '', 'se',
776 sprintf( _("%s to %s"),_("Spanish"),_("English"))) ;
777 echo "</select><br />\n";
778 echo "<input type=\"hidden\" name=\"template\" value=\"General\" />\n";
779 echo 'PROMT: <input type="submit" value="' . _("Translate") . '" />';
780
781 translate_table_end();
782 }
783
784 /**
785 * google translation engine
786 *
787 * @param string $message text that has to be translated
788 * @access private
789 */
790 function translate_form_google($message) {
791 translate_new_form('http://www.google.com/translate_t');
792 ?>
793 <input type="hidden" name="ie" value="Unknown" />
794 <input type="hidden" name="oe" value="ASCII" />
795 <input type="hidden" name="hl" value="en" />
796 <input type="hidden" name="text" value="<?php echo $message; ?>" />
797 <select name="langpair"><?php
798 echo translate_lang_opt('en_US', 'de_DE', 'en|de',
799 sprintf( _("%s to %s"),_("English"),_("German"))) .
800 translate_lang_opt('en_US', 'es_ES', 'en|es',
801 sprintf( _("%s to %s"),_("English"),_("Spanish"))) .
802 translate_lang_opt('en_US', 'fr_FR', 'en|fr',
803 sprintf( _("%s to %s"),_("English"),_("French"))) .
804 translate_lang_opt('en_US', 'it_IT', 'en|it',
805 sprintf( _("%s to %s"),_("English"),_("Italian"))) .
806 translate_lang_opt('en_US', 'pt*', 'en|pt',
807 sprintf( _("%s to %s"),_("English"),_("Portuguese"))) .
808 translate_lang_opt('de_DE', 'en_US', 'de|en',
809 sprintf( _("%s to %s"),_("German"),_("English"))) .
810 translate_lang_opt('de_DE', '', 'de|fr',
811 sprintf( _("%s to %s"),_("German"),_("French"))) .
812 translate_lang_opt('es_ES', '', 'es|en',
813 sprintf( _("%s to %s"),_("Spanish"),_("English"))) .
814 translate_lang_opt('fr_FR', '', 'fr|en',
815 sprintf( _("%s to %s"),_("French"),_("English"))) .
816 translate_lang_opt('fr_FR', '', 'fr|de',
817 sprintf( _("%s to %s"),_("French"),_("German"))) .
818 translate_lang_opt('it_IT', '', 'it|en',
819 sprintf( _("%s to %s"),_("Italian"),_("English"))) .
820 translate_lang_opt('pt*', '', 'pt|en',
821 sprintf( _("%s to %s"),_("Portuguese"),_("English")));
822 echo '</select>'.
823 'Google: <input type="submit" value="' . _("Translate") . '" />';
824
825 translate_table_end();
826 }
827 ?>