collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: module for translation (to german)  (Read 3991 times)

0 Members and 1 Guest are viewing this topic.

Offline lulifuz

  • BeBot User
  • **
  • Posts: 40
  • Karma: +0/-0
module for translation (to german)
« on: June 10, 2006, 08:00:38 pm »
Hi there,

this is an in-game translation module which translates text to German. It uses Altavistas Bablefish for translation.

This is just a quick hack with some code that I grabbed from this site: http://vivaolinux.com.br/scripts/verScript.php?codigo=512

This was made upon a request from some org member with limited English skills.
I am in no way a php-programmer so I am happy I got that far.

But I think there are more people out there that would be happy to have a in-game translation tool.
So maybe some on of the bebot wizards can come up with a real solution?

In the original code there has even been the possibility to chose the language. That could be also very usefull I suppose.

However, just thought this is a good idea that should not get lost.

Greets,

 lulifuz

Code: [Select]
<?
  /*
   * De.php - translates english text to german.
   *
   * a module for
   * BeBot - An Anarchy Online Chat Automaton
   *
   */


  $de = new De($bot);

  $commands["tell"]["de"] = &$de;
  $commands["pgmsg"]["de"] = &$de;
  $commands["gc"]["de"] = &$de;


  /*
    The Class itself...
  */
  class De
  {
    var $bot;
   
   

    /*
      Constructor:
        Hands over a referance to the "Bot" class.
    */
    function De (&$bot)
    {
      $this -> bot = &$bot;
    }



    /*
      This gets called on a tell with the command
    */
    function tell($name, $msg)
    {
       if (preg_match("/^" . $this -> bot -> commpre . "de (.+)$/i", $msg, $info))
        $this -> bot -> send_tell($name, $this -> make_reply($info[1]));
       else
      $this -> bot -> send_help($name);
    }

    /*
      This gets called on a msg in the privgroup with the command
    */
    function pgmsg($name, $msg)
    {
      if (preg_match("/^" . $this -> bot -> commpre . "de (.+)$/i", $msg, $info))
        $this -> bot -> send_pgroup($this -> make_reply($info[1]));
    }

    /*
      This gets called on a msg in the guildchat with the command
    */
    function gc($name, $msg)
    {
      if (preg_match("/^" . $this -> bot -> commpre . "de (.+)$/i", $msg, $info))
        $this -> bot -> send_gc($this -> make_reply($info[1]));
    }

    function make_reply($inmsg)
    {
        return $this -> traduzir($inmsg, "en_de");
    }
   
   
    function strtoupper_utf8($string)
    {
       $string=utf8_decode($string);
       $string=strtoupper($string);
       /* $string=utf8_encode($string); */
       return $string;
    }

/*
Programado por F?io Berbert de Paula <[email protected]>
http://www.vivaolinux.com.br

Script usado para traduzir texto em diversos idiomas usando a engine
do babelfish.altavista.com como fonte de pesquisa.

Rio de Janeiro, 29/07/2002
*/

// fun?o usada para traduzir um texto
function traduzir($urltext,$lp) {
   // defini?o de vari?eis
   $host = 'babelfish.altavista.com';
   $vars = "doit=$DOIT&tt=$TT&urltext=" . urlencode(utf8_encode($urltext)) . "&lp=$lp";
   $url  = "/tr?$vars";
   // efetuando conex? com o babelfish
   $fp = fsockopen ($host, 80, $errno, $errstr, 30);
   if (!$fp) {
       $traducao = "Fehler: $host: $errstr ($errno)<br>\n";
       exit;
   } else {
// Accept-Language: en
// Accept-Charset: iso-8859-1,*,utf-8
       $addinfo .= "Accept-Language: en\r\nAccept-Charset: iso-8859-1,*,utf-8\r\n";
       fputs ($fp, "GET $url HTTP/1.1\r\nHost: $host\r\n$addinfo\r\n");
       while (!feof($fp)) {
           $html .= fgets ($fp,128);
       }
       fclose ($fp);
   }
   // removendo quebras de linhas do resultado
   $html = ereg_replace("\n"," ",$html);

   // capturando o texto rtaduzido
   ereg("name=\"q\" value=(.*)>",$html,$saida);
   $traducao = $saida[1];
   $traducao = ereg_replace(">.*$","",$traducao);
   // decodificar a string
   $traducao = utf8_decode($traducao);
   return($traducao);
}

  }
?>


Offline tabsl

  • BeBot Rookie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: module for translation (to german)
« Reply #1 on: June 21, 2006, 12:53:45 pm »
Hmm, works fine except sometimes it returns nothing but a clear line.  :-X

Offline lulifuz

  • BeBot User
  • **
  • Posts: 40
  • Karma: +0/-0
Re: module for translation (to german)
« Reply #2 on: June 26, 2006, 06:38:25 am »
Hi there,

you are right, got this also sometimes.
Could have several reasons as I am not doing any error checking ;-)
May be bablefish is not reachable or the word can not be translated.
Hm, if I find some time I gonna try some things out, maybe I can fix it.

Greetings,

   lulifuz

joey12344

  • Guest
Re: module for translation (to german)
« Reply #3 on: June 29, 2006, 07:28:42 pm »
Wow nice work :D Now only if babelfish wasnt nerfed..

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 371
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal