Skip to content
Browse files

ignore empty

  • Loading branch information...
1 parent 8df0b31 commit 8126dc928122b173644038f4b154b8817ef8f2bb @mattn mattn committed Oct 29, 2010
Showing with 14 additions and 10 deletions.
  1. +14 −10 plugin/googletranslate.vim
View
24 plugin/googletranslate.vim
@@ -4,7 +4,7 @@
"
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Based On: excitetranslate.vim
-" Last Change: 28-Oct-2010.
+" Last Change: 29-Oct-2010.
if !exists('g:googletranslate_options')
let g:googletranslate_options = ["register","buffer"]
@@ -47,15 +47,19 @@ function! GoogleTranslate(word, ...)
let text = substitute(text, '\\u\(\x\x\x\x\)', '\=s:nr2enc_char("0x".submatch(1))', 'g')
let [null,true,false] = [0,1,0]
let obj = eval(text)
- let text = obj.responseData.translatedText
- let text = substitute(text, '&gt;', '>', 'g')
- let text = substitute(text, '&lt;', '<', 'g')
- let text = substitute(text, '&quot;', '"', 'g')
- let text = substitute(text, '&apos;', "'", 'g')
- let text = substitute(text, '&nbsp;', ' ', 'g')
- let text = substitute(text, '&yen;', '\&#65509;', 'g')
- let text = substitute(text, '&#\(\d\+\);', '\=s:nr2enc_char(submatch(1))', 'g')
- let text = substitute(text, '&amp;', '\&', 'g')
+ if type(obj.responseData) == 4
+ let text = obj.responseData.translatedText
+ let text = substitute(text, '&gt;', '>', 'g')
+ let text = substitute(text, '&lt;', '<', 'g')
+ let text = substitute(text, '&quot;', '"', 'g')
+ let text = substitute(text, '&apos;', "'", 'g')
+ let text = substitute(text, '&nbsp;', ' ', 'g')
+ let text = substitute(text, '&yen;', '\&#65509;', 'g')
+ let text = substitute(text, '&#\(\d\+\);', '\=s:nr2enc_char(submatch(1))', 'g')
+ let text = substitute(text, '&amp;', '\&', 'g')
+ else
+ let text = ''
+ endif
return text
endfunction

0 comments on commit 8126dc9

Please sign in to comment.
Something went wrong with that request. Please try again.