Google Translate suggestion in Opera

Posted on:

There is a way to add Google Translate suggestions in Opera (at least, for those who has PHP on local machine; if you don't, please choose any free PHP hosting with allowed HTTP request). So, firstly create and upload such PHP file:

<?php
header('Content-Type: text/javascript');

$q = stripslashes($_GET['q']);
$sl = $_GET['sl']; $tl = $_GET['tl'];

$t = file_get_contents('http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=' . urlencode($q) . '&langpair=' . urlencode($sl) . '|' . urlencode($tl));
$a = json_decode($t, true);
echo json_encode($a['responseStatus'] != 200 ? array() : array($q, array($a['responseData']['translatedText'])));

It will return google translate using OpenSearch formatting.

Then, you should open search.ini (in profile folder) and find there your Google Translate's section. Add those two lines to it:

Suggest Protocol=JSON
Suggest URL=http://localhost/gsearch.php?q={SearchTerm} (your URL)

Restart Opera. That's all.


More posts: