Simple Machines Community Forum

SMF Development => Feature Requests => Applied or Declined Requests => Topic started by: Acf on September 27, 2005, 01:23:01 PM

Title: translation
Post by: Acf 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
Title: Re: translation
Post by: AzaToth on September 27, 2005, 02:16:37 PM
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.
Title: Re: translation
Post by: AzaToth on September 27, 2005, 02:21:46 PM
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($handle, 8192);

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'));
?>
Title: Re: translation
Post by: Acf on September 27, 2005, 02:28:17 PM
lol  ;)
Title: Re: translation
Post by: AzaToth on September 27, 2005, 06:05:16 PM
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?
Title: Re: translation
Post by: Acf on September 28, 2005, 05:35:31 AM
Great!, it might be possible... but i am not scripting kid... iam a designer  ;D
Title: Re: translation
Post by: Dannii on September 28, 2005, 08:07:28 AM
Whoa! Mod-writing machine!
Title: Re: translation
Post by: 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
Title: Re: translation
Post by: AzaToth on September 28, 2005, 10:41:48 AM
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.
Title: Re: translation
Post by: Mohammad on April 19, 2007, 10:16:59 AM
can any body make something like this for smf?

http://www.joomlaspan.com/joomla-downloads/Download/-JoomlaspanModules/GoogleTranslationModule/

it would be useful!