Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: search-failed ",tkk:'" #137

Open
jumper047 opened this issue Oct 28, 2020 · 9 comments
Open

Error: search-failed ",tkk:'" #137

jumper047 opened this issue Oct 28, 2020 · 9 comments

Comments

@jumper047
Copy link
Contributor

Error appears when I trying to translate someghing.
There is debugger output:

Debugger entered--Lisp error: (search-failed ",tkk:'")
  search-forward(",tkk:'")
  google-translate--search-tkk()
  google-translate--get-b-d1()
  google-translate--gen-tk("test")
  google-translate--request("en" "ru" "test")
  google-translate-request("en" "ru" "test")
  google-translate-translate("en" "ru" "test")
  %google-translate-query-translate(nil nil)
  google-translate-query-translate(nil)
  #<subr funcall-interactively>(google-translate-query-translate nil)
  apply(#<subr funcall-interactively> (google-translate-query-translate nil))
  funcall-interactively(google-translate-query-translate nil)
  #<subr call-interactively>(google-translate-query-translate nil nil)
  apply(#<subr call-interactively> (google-translate-query-translate nil nil))
  explain-pause--wrap-call-interactively(#<subr call-interactively> google-translate-query-translate nil nil)
  apply(explain-pause--wrap-call-interactively #<subr call-interactively> (google-translate-query-translate nil nil))
  call-interactively(google-translate-query-translate nil nil)
  command-execute(google-translate-query-translate)
@parjanya
Copy link

parjanya commented Nov 5, 2020

I’m having the same issue. Apparently the tkk doesn’t always appear on the page anymore. This is very crude, but seems to work:

(defun google-translate--search-tkk ()
  "Get the Token-Key from the page buffer."
  (let (downloaded)
    (setq downloaded (shell-command-to-string "curl -s --user-agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18' 'https://translate.google.com' | sed 's/,/\\n,/g' | grep ',tkk'"))
    (print downloaded)
    (with-temp-buffer (insert downloaded)
		      (goto-char 0)
		      (re-search-forward ",tkk:'\\([0-9]+\\)\\.\\([0-9]+\\)")
		      (list (string-to-number (match-string 1))
			    (string-to-number (match-string 2))))))

Sometimes it appears not to work on the first time, but on the second one it does work. I have no idea why.

@leuven65
Copy link
Contributor

leuven65 commented Nov 9, 2020

I also have same issue.
There is some discussion in #52
I found that following way also works Ok:

(defun google-translate--search-tkk ()
  "Search TKK."
  (list 430675 2721866130))

@rileyrg
Copy link

rileyrg commented Nov 16, 2020

(defun google-translate--search-tkk ()
"Search TKK."
(list 430675 2721866130))

I was messing around for ages and finally this form works for using straight/use-package. The require in the :init was the key. Zero clues as to why.


     (use-package google-translate
       :demand t
       :init
            (require 'google-translate)

       :functions (my-google-translate-at-point google-translate--search-tkk)
       :custom
       (google-translate-backend-method 'curl)
       :config
       (defun google-translate--search-tkk () "Search TKK." (list 430675 2721866130))
       (defun my-google-translate-at-point()
         "reverse translate if prefix"
         (interactive)
         (if current-prefix-arg
             (google-translate-at-point)
           (google-translate-at-point-reverse)))
       :bind
       ("C-t". my-google-translate-at-point))

@jcs090218
Copy link
Contributor

jcs090218 commented Dec 10, 2020

Same issue here. 😕

@atykhonov @stardiviner Any idea? Thanks!

@stardiviner
Copy link
Collaborator

@jcs090218 As upper mentioned #52 problem. For now, there is no prefect solution. You can use upper temporary solution. Seems Google Translate return different values on different machines and requests.

@parjanya
Copy link

@stardiviner
Copy link
Collaborator

Check out this old issue #52 for more information.

@dodona2
Copy link

dodona2 commented Feb 24, 2021

confirm that:
Contacting host: translate.google.com:80
uncompressing publicsuffix.txt.gz...done
Opening TLS connection to ‘translate.google.com’...
Opening TLS connection with ‘gnutls-cli --x509cafile /etc/pki/tls/certs/ca-bundle.crt -p 443 translate.google.com’...done
Opening TLS connection to ‘translate.google.com’...done
google-translate--search-tkk: Search failed: ",tkk:'"
Package tls is deprecated

@dodona2
Copy link

dodona2 commented Apr 28, 2021

2 months later, still a mess:
Contacting host: translate.google.com:80
Opening TLS connection to ‘translate.google.com’...
Opening TLS connection with ‘gnutls-cli --x509cafile /etc/pki/tls/certs/ca-bundle.crt -p 443 translate.google.com’...done
Opening TLS connection to ‘translate.google.com’...done
Opening TLS connection to ‘consent.google.com’...
Opening TLS connection with ‘gnutls-cli --x509cafile /etc/pki/tls/certs/ca-bundle.crt -p 443 consent.google.com’...done
Opening TLS connection to ‘consent.google.com’...done
Opening TLS connection to ‘consent.google.com’...
Opening TLS connection with ‘gnutls-cli --x509cafile /etc/pki/tls/certs/ca-bundle.crt -p 443 consent.google.com’...done
Opening TLS connection to ‘consent.google.com’...done
google-translate--search-tkk: Search failed: ",tkk:'"
Package tls is deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants