ставим
sudo gem install google_translate
Добавляем следующую комманду для всех типов фаилов. Результат - tooltip, Источник - selected text or word. Сначала смотрим если слово уже искалось, если нет - идем в гугл.
require 'rubygems'
require 'google_translate'
dict = "~/dict"
space=" - "
text= STDIN.read
local_trans = `cat #{dict} | grep '#{text.strip}#{space}'`
if(local_trans.empty?())
trans = Google::Translate.new().translate(:from => "en", :to => "ru", :text =>text)
`echo '#{[text,space,trans].join}' >> ~/dict`
puts(trans)
else
puts("local:"+local_trans.split("-").last.strip)
end
горячую клавишу я повесил на CMD+J (было свободно)
работает очень бысто (менее секунды на поиск, если локально - тогда мгновенно)

3 comments:
I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
Joannah
http://transcendmemory.net
hello,
I found and tried this free unlimited sms to all network website. You can send unlimited texts to all Philippine subscribers.
We can also meet new friends and txtmates through discussion and chat.
Visit this link http://www.txtmate.com
Post a Comment