Tuna wrote:
>> Kurt Granroth wrote:
>>
>>> jdawg wrote:
>>>
>>>> I am wanting to do a quick way to get english-spanish/spanish-english
>>>> translation ultimately from the command line.
>>>>
>>>> As a first step, I tried this:
>>>> wget 'http://translate.google.com/translate_t#es|en|pavimentado'
>>>>
>>>> and I got this back:
>>>> ---------- error -----------
>>>> --08:49:36-- http://translate.google.com/translate_t
>>>> => `translate_t'
>>>> Resolving translate.google.com... 74.125.95.113, 74.125.95.100,
>>>> 74.125.95.101, ...
>>>> Connecting to translate.google.com|74.125.95.113|:80... connected.
>>>> HTTP request sent, awaiting response... 403 Forbidden
>>>> 08:49:41 ERROR 403: Forbidden.
>>>> ---------- end of error ----------
>>>>
>>>> So does anyone know a site where I can do this kind of thing. all the
>>>> ones I have found so far, won't let you do it.
>>>>
>>> The output for that would be tricky to handle, even if it did work,
>>> since that URL returns a fully formatted HTML page. You would have to
>>> do a lot of HTML parsing from the command line.
>>>
>>> A far better route would be to use the Google API.
>>>
>>> http://code.google.com/apis/ajaxlanguage/documentation/
>>>
>>> The docs they have there are all Javascript specific, but at the core,
>>> it's all just JSON formatted requests and responses over HTTP. 'wget'
>>> and 'sed' should be able to make quick work of them. If not, maybe you
>>> could create a couple line perl wrapper?
>>>
>>> Here's some example uses of the Google API (not the language one, but
>>> the concept is identical) in other languages:
>>>
>>> http://code.google.com/apis/ajaxsearch/documentation/index.html#fonje_snippets
>>>
>> And, to follow up to myself, here is an example using curl and sed.
>> wget works just as well... I used curl here only because it's one
>> command line option easier to output to stdout:
>>
>> $ curl --silent
>> "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=hello&langpair=en%7Ces"
>> | sed -e 's,^.*translatedText":",,g' -e 's,"}.*$,,g'
>> hola
>>
>> Kurt
>>
>>
>
> My friend wrote a python script that does all this. Some IRC'ers in here
> will remember bobsalad, he uses this script now.
>
> http://www.coderprofile.com/networks/source-codes/521/google-translator-script
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
>
haven't had much to do with python yet (turned off by the block
indentation thing), mostly a perl and bash guy.
but I thank you for the url of above. this is what I really hoped for.
something like this works just fine
i will write my own bash script to translate all kinds of text using
this technique.
it works as expected in the other direction:
curl --silent
"
http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=pavimentada%20primario&langpair=es%7Cen"
jerry
--
Happy Trails!
Jerry (K7AZJ)
Hobbit Name: Pimpernel Loamsdown
Registered Linux User: 275424
This email's random fortune:
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss