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