Open jumper047 opened 3 years ago
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.
I also have same issue. There is some discussion in https://github.com/atykhonov/google-translate/issues/52 I found that following way also works Ok:
(defun google-translate--search-tkk ()
"Search TKK."
(list 430675 2721866130))
(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))
Same issue here. 😕
@atykhonov @stardiviner Any idea? Thanks!
@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.
they changed their API: https://github.com/Boudewijn26/gTTS-token/blob/master/docs/november-2020-translate-changes.md
Check out this old issue #52 for more information.
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
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
Error appears when I trying to translate someghing. There is debugger output: