News:

Wondering if this will always be free?  See why free is better.

Main Menu

translation

Started by Acf, September 27, 2005, 01:23:01 PM

Previous topic - Next topic

Acf

A http://babelfish.altavista.com/ like translation system intergrated would be cool. so that i can "try to understand" what everybody is saying in chinees on aboard :P
Sigh...

AzaToth

Quote from: ªcF on September 27, 2005, 01:23:01 PM
A http://babelfish.altavista.com/ like translation system intergrated would be cool. so that i can "try to understand" what everybody is saying in chinees on aboard :P
comming, wait a few minutes.

AzaToth

just made a interface to google translator:

<?php
class GoogleTranslator {
static function translate($text$langpair) {
$url 'http://translate.google.com/translate_t?';
$data = array(
'text' => $text,
'langpair' => $langpair,
);
$handle fopen($url http_build_query($data), 'r');
if(!$handle)
return '';
while (!feof($handle)) 
$contents .= fread($handle8192);

fclose($handle);
preg_match('#\<textarea.*?\>(.*?)\<\/textarea\>#'$contents$matches);

return $matches[1];
}

static function getPairCode($pair) {
$languagePairs = array(
'Chinese Simplified to English' => 'zh-CN|en',
'English to Chinese Simplified' => 'en|zh-CN',
'English to French' => 'en|fr',
'English to German' => 'en|de',
'English to Italian' => 'en|it',
'English to Japanese' => 'en|ja',
'English to Korean' => 'en|ko',
'English to Portuguese ' => 'en|pt',
'English to Spanish ' => 'en|es',
'French to English' => 'ft|en',
'French to German' => 'ft|de',
'German to English' => 'de|en',
'German to French' => 'de|fr',
'Italian to English' => 'it|en',
'Japanese to English' => 'ja|en',
'Korean to English' => 'ko|en',
'Portuguese to English' => 'pt|en',
'Spanish to English' => 'es|en',
);
return $languagePairs[$pair];
}
}

echo 
GoogleTranslator::translate("Hello World"GoogleTranslator::getPairCode('English to French'));
?>

Acf

Sigh...

AzaToth

Quote from: ªcF on September 27, 2005, 02:28:17 PM
lol  ;)
Happy now?
http://mods.simplemachines.org/index.php?mod=201

P.S. didn't make it to parse any bbcode inside, you have any idea if it's possible?

Acf

Great!, it might be possible... but i am not scripting kid... iam a designer  ;D
Sigh...

Dannii

Whoa! Mod-writing machine!
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Grudge

I believe SMF has a function called unparse_bbc or similar - for sending emails etc. You want to do that before translating
I'm only a half geek really...

AzaToth

Quote from: Grudge on September 28, 2005, 10:06:25 AM
I believe SMF has a function called unparse_bbc or similar - for sending emails etc. You want to do that before translating
Ok, i'll look into it.

Mohammad


Advertisement: