args-out-of-range error in google-translate-json-suggestion
kiwonum opened this issue · 7 comments
Hello, recently, google-translate-buffer has started showing the error message:
Debugger entered--Lisp error: (args-out-of-range [] 1)
google-translate-json-suggestion(...)
google-translate-translate("auto" "en" "...")
google-translate-buffer(nil)
funcall-interactively(google-translate-buffer nil)
call-interactively(google-translate-buffer nil nil)
command-execute(google-translate-buffer)
(I just replaced some texts with "..." in my quote.)
I think it's because of this part:
(defun google-translate-json-suggestion (json)
"Retrieve from JSON (which returns by the
`google-translate-request' function) suggestion. This function
does matter when translating misspelled word. So instead of
translation it is possible to get suggestion."
(let ((info (aref json 7)))
(when info
(aref info 1)))) <---------
Hacked it up and was able to get results back:
(defun google-translate-json-suggestion (json)
"Retrieve from JSON (which returns by the
`google-translate-request' function) suggestion. This function
does matter when translating misspelled word. So instead of
translation it is possible to get suggestion."
(let ((info (aref json 7)))
(if (and info (> (length info) 0))
(aref info 1)
nil)))
I don't know if the suggestion is just placed somewhere else or it really doesn't exist and we should gate against that.
Hacked it up and was able to get results back
I think you should do a pull request.
Hacked it up and was able to get results back
I think you should do a pull request.
Agree with @sudoLife, please @jojojames do a pull request for it.
Similar WA works for me as well
`--- a/google-translate-core.el
+++ b/google-translate-core.el
@@ -252,7 +252,7 @@ speech."
does matter when translating misspelled word. So instead of
translation it is possible to get suggestion."
(let ((info (aref json 7)))
- (when info
+ (when (and info (> (length info) 0))
(aref info 1))))
(defun google-translate-version ()`
@jojojames I had the same issue, but your patch fixed it. I agree with the rest, please turn it into a PR so this is fixed for everyone.
@atykhonov Also please take a look at this issue and see if his fix is sufficient. This issue has been plaguing me for quite some time and it was really nice to have Google Translate working in Emacs again, even if only via a workaround.
I don't have much time right now to handle a back and forth pull request (especially since the change looks like a hack) so I'd recommend someone else do it if they were inclined.
I don't have much time right now to handle a back and forth pull request (especially since the change looks like a hack) so I'd recommend someone else do it if they were inclined.
I'll have it a look.