On Sun, Mar 29, at 09:16 JuanPablo wrote:
> 
> this is my solution
> 
> function! Translate(entrada)
>         let en=substitute(a:entrada," ","%20","")
>         let en = substitute(en, "[ ]*$","","")
>         let  palabra= system('curl -e www.google.com
> "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q='.en.'&langpair=en%7Ces"')
>         echo  split(strpart(palabra,stridx(palabra,"Text") + 7 ),'\"')[0]
> endfunction

You can also convert the returned string into a dictionary, here is the
alternative:

function! Translate(entrada)
        let en=substitute(a:entrada," ","%20","")
        let en = substitute(en, "[ ]*$","","")
        let palabra= system('curl -e www.google.com 
"http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q='.en.'&langpair=en%7Ces"')
        let dict = eval(substitute(palabra, 'null', '"&"', ''))
        return dict["responseData"]["translatedText"]
endfunction

echo Translate("Heloo world")  => Hola Mundo

> JuanPablo

By the way, is a good idea for a plugin.

Regards,
Agathoklis.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to