View Single Post
Old 08-01-2011, 03:42 AM  
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,347
Using Google Translate with CyberSEO

Ok, here is the manual on how to use Google Translator with the CyberSEO plugin.

1) Syndicate the feed your are going to pull posts from.
2) In the feed options menu post the following code into the "PHP Code <?php .. ?>" box:
Code:
// Set source language, e.g. English
$s = 'en';
// Set destination language, e.g. German
$d = 'de';
if ($post ['post_content'] == '') {
    $post ['post_content'] = $post ['post_excerpt'];
}
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&amp;q=' . urlencode ( $post ['post_content'] ) . '&amp;langpair=' . urlencode ( $s . '|' . $d ) );
curl_setopt ( $ch, CURLOPT_REFERER, 'http://www.yoursite.com/translate.php' );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
$json = json_decode ( curl_exec ( $ch ), true );
$post ['post_content'] = $json ['responseData'] ['translatedText'];
3) Save the settings and pull the feed.

Done!

The code above has two variables: $s and $d. Use them to set source and destination language for your feed. For example, if you want to translate the Danish feed to Spanish, use the following values:
$s = 'da';
$d = 'es';

Now you can use the Google translator with CyberSEO.

That's very easy. Isn't it?
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote