PHP-Einfach.de PHP lernen leicht gemacht

Navigation
» Startseite
» Newsübersicht
» Kontakt
» Impressum

Community
» Forum
» Gästebuch

Tutorial
» PHP Tutorial
» MySQL Tutorial
» PHP
» MySQL
» Codeschnipsel

Downloads
» Einführung
» Scripts
» Command Board

Sonstiges
» md5-Generator
» Generator
» Wissenswertes

PHP lernen


Dieses Projekt wird unterstützt von
Lichteffekte Shop

 
Partner:
PHP Forum
Mathe Nachhilfe
Suchmaschinenoptimierung

Übersetzung

Zurück zur Übersicht

Diese Funktion dient zur Übersetzung mittels Babelfish von einzelnen Texten.

 PHP 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:

<?php
  
function translate($text,$l2l) {
    if (
substr_count($text," ")+1>180) return "Only text blocks with less then 180 words are allowed.";

    
$host "babelfish.altavista.com";
    
$data_to_send "doit=done&intl=1&tt=urltext&trtext=$text&lp=$l2l&btnTrText=Translate";

    
$fp fsockopen($host80);
    
fputs($fp"POST /tr HTTP/1.1\r\n");
    
fputs($fp"Host: $host\r\n");
    
fputs($fp"Referer: http://babelfish.altavista.com/tr\r\n");
    
fputs($fp"Content-type: application/x-www-form-urlencoded\r\n");
    
fputs($fp"Content-length: ".strlen($data_to_send)."\r\n");
    
fputs($fp"Connection: close\r\n\r\n");
    
fputs($fp$data_to_send);
    
$html "";
    while(!
feof($fp)) $html .= fgets($fp128);

    
$p1 strpos($html,"<td bgcolor=white class=s><div style=padding:10px;>")+51;
    if (!
$p1) return "Could not translate.";
    
$p2 strpos($html,"</div></td>",$p1);
    if (!
$p2) return "Could not translate.";
    return 
substr($html,$p1,$p2-$p1);
  }
?>


Aufruf:
 PHP 
1:
2:
3:
4:

<?php
translate
("Some text.","en_de");
?>


Es werden natürlich nur alle Übersetzung unterstützt die auch von Babelfish unterstützt werden.

Kommentare

Zurück zur Übersicht

Autor Schneemann

News
13.08 - » Spam im Gästebuch
Endlich Schluss mit dem Spam

08.12 - » Clanletter 2.0
Clanletter wurde komplett neu programmiert

01.09 - » Command Board 1.0 - 2.0
Das Command Board 1.0 Beta 2.0 ist erschienen


Mehr

Forum
» Entwickler Forum

» insert nach login

» Tabellenzelle zu groß







© PHP-Einfach.de 2003 - 2012