google-translate icon indicating copy to clipboard operation
google-translate copied to clipboard

Failed to search TKK

Open renatofdds opened this issue 9 years ago • 70 comments

Any translation attempt is failing with the error: google-translate--search-tkk: Failed to search TKK

renatofdds avatar Jun 15 '16 23:06 renatofdds

Hi @renatofdds,

which version do you use? M-x google-translate-version RET.

atykhonov avatar Jun 16 '16 11:06 atykhonov

I'm also having this problem. Using most recent version 0.11.11

ardangelo avatar Jun 30 '16 16:06 ardangelo

I'm also on 0.11.11

renatofdds avatar Jun 30 '16 18:06 renatofdds

Facing the same issue on 0.11.11. Any help is highly appreciated, BTW, I am behind a http proxy.

jack836 avatar Sep 09 '16 04:09 jack836

Hi all!

I have no idea what exactly could be the root cause of the issue. But with your help I believe the reason could be discovered and the issue fixed.

I've just pushed the code (0.11.12 version) which should help us to debug the issues which relate to retrieving of TKK.

With these changes, please, execute M-: (setq google-translate--tkk-debug t) RET (or M-x eval-expression RET (setq google-translate--tkk-debug t) RET). Then try to translate a word/sentence as usually you do. As the result, two buffers should appear. First one usual one (*Google Translate*) with the translation, and the second one (*Google Translate Debug*) with the debug info, i.e. HTML which is used for retrieving of TKK. Then please paste the contents of *Google Translate Debug* buffer here.

atykhonov avatar Sep 09 '16 18:09 atykhonov

If you'll see that someone already posted the similar output as you get, please feel free to post it again, or just notify that you get the same output. I just believe that additional information would be helpful.

Actually any help is highly appreciated!

Thank you in advance!

atykhonov avatar Sep 09 '16 18:09 atykhonov

Thank you for the efforts and further steps. I will report the test results soon.

jack836 avatar Sep 12 '16 09:09 jack836

After upgrading to 0.11.12 and setting the debug to true as you suggested I did a google-translate-smooth-translate.

I don't see two windows open and I receive the same error. This is what happens

Translate : "The text to be translated appears here correctly (Japanese)" RET Translate from : Japanese RET Translate to : English RET connecting to proxy.xxx.xxx.xx Failed to Search TKK

But version 0.11.10 works perfectly at my home computer (11.11 and 11.12 not tested yet). The above test was from my office computer and the only difference is that, the office computer is behind a http proxy. So I strongly doubt it has something to do with proxy.

Further testing for connection through proxy

  1. 'wget' from terminal connects successfully to http and https 2.'eww' from emacs connects to http but fails to establish a connection to https
  2. 'package-list-packages' from emacs downloads successfully from http sources (melpa and org) but fails to download from https source (marmalade)

Since google translate has to establish a connection to https://translate.google.com, i strongly suspect it has something to do with my proxy setting. Sorry if I wasted your time.

But I would sincerely appreciate if you can point out some ways I can make it to work in my work-computer behind proxy. I also hope many people need google translate in their office computer which is normally behind a proxy.

Thank you for your time and efforts

jack836 avatar Sep 13 '16 07:09 jack836

Interesting. My case is opposite. While it works on my office computer, doesn't work on my home computer. Both uses same emacs settings including google-translate's versions(0.11.13).

EDITED:

  • works on my ~~home~~ office computer
  • doesn't work on my ~~office~~ home computer

rfkm avatar Dec 09 '16 01:12 rfkm

SOLVED The issue was Emacs-25.0 was using the "GET method" to connect to HTTPS sites, which my company's firewall (proxy) didn't like. The solution is to make Emacs use the "CONNECT method" to request connection to HTTPS sites (which the proxy allows). The following page correctly directed me towards the solution.

http://emacs.1067599.n8.nabble.com/bug-11788-url-http-does-not-properly-handle-https-over-proxy-td46070.html

Either modify that one particular .el file and rebuild you emacs OR update to 'emacs-snapshot' version-26. I took the easier step and updated to Emacs-26.0.50.2. Now google-translate works like a charm within emacs. Thank you all for the pointers and support

jack836 avatar Dec 09 '16 07:12 jack836

@jack836 Good news. Thank you for sharing. BTW, I've edited my comment since it was wrong. My home network doesn't use a proxy AFAIK, but it seems worthwhile to try that. Again, thanks!

rfkm avatar Dec 09 '16 15:12 rfkm

When I updated Emacs 25.1 to Emacs 25.2, I found the issue.

The issue is solved on my PC when google-translate package turns to request through HTTPS but not HTTP by setting google-translate-base-url and google-translate--tkk-url as follows

  (when (and (= emacs-major-version 25) (<= emacs-minor-version 2))
    (setq google-translate-base-url
          "https://translate.google.com/translate_a/single"
          google-translate--tkk-url
          "https://translate.google.com/"))

I am uncertain about the issue at Emacs 25.1 @jack836 mentions above that the problem is solved at Emacs 26 https://github.com/atykhonov/google-translate/issues/52#issuecomment-265949189

Wish it will be helpful.

Info:

Emacs version "25.2.1" which is built with GnuTLS library
(google-translate-version) says "Google Translate (version): 0.11.14"
google-translate package is installed via MELPA version 20170713.119; not MELPA stable

ikedaisuke avatar Sep 10 '17 09:09 ikedaisuke

I met the same problem. After configuring a socks5 proxy for emacs, the problem got addressed. Maybe it's concerning to the ISP, who blocks the network traffic to google services. However, I found something weired. With network proxy set globally in gnome 3, the google services can be visited by firefox browser, but they are not available in eww web browser in emacs. The socks5 proxy settings in gnome 3 seems to be ignored.

example socks5 proxy for emacs:

(setq url-gateway-method 'socks)
(setq socks-server '("Default server" "127.0.0.1" 1080 5))

crystle9 avatar Jul 28 '18 14:07 crystle9

This just started happening to me after months without a problem. But, it went away after a few minutes. I am not using a proxy.

UPDATE: Now using a different computer that also worked without a problem. It's now failing with the same message. 💻🔨

sshaw avatar Sep 20 '18 15:09 sshaw

Same problem here. It has been working for months without a problem, but now i get google-translate--search-tkk: Failed to search TKK all the time. I tried to set google-translate--tkk-debug to true, but no second buffer with debug info appears.

rantonse avatar Sep 21 '18 07:09 rantonse

Same problem here. It has been working for months without a problem, but now i get google-translate--search-tkk: Failed to search TKK all the time. I tried to set google-translate--tkk-debug to true, but no second buffer with debug info appears.

same issue here /'' (;;Emacs version 25.3; google-translate version 0.11.14)

touxstone avatar Sep 21 '18 17:09 touxstone

same here

GNU Emacs 26.1
Google Translate (version): 0.11.14

aanoaa avatar Sep 21 '18 22:09 aanoaa

The problem seems to be that the google-translate--tkk-regex definition in google-translate-tk.el,

https://github.com/atykhonov/google-translate/blob/d8b84a8359fcc697114d1298840e9a45b111c974/google-translate-tk.el#L50

does not match the appropriate string in the retrieved HTML document, which in my case was

TKK='427110.1469889687'.

I'm also running Emacs 26.1 and version 0.11.14.

rantonse avatar Sep 22 '18 07:09 rantonse

same here, I'm investigating and looking for a solution

atykhonov avatar Sep 22 '18 12:09 atykhonov

does not match the appropriate string in the retrieved HTML document

yes, previously HTML had something like the following:

TKK=eval('((function(){var a\x3d3470396290;var b\x3d183821724;return 426874+\x27.\x27+(a+b)})())');

now we have this representation: TKK='427116.3269864724';.

atykhonov avatar Sep 22 '18 13:09 atykhonov

@atykhonov @rantonse

I found a quick fix. Try it:

(when (and (string-match "0.11.14"
                         (google-translate-version))
           (>= (time-to-seconds)
               (time-to-seconds
                (encode-time 0 0 0 23 9 2018))))
  (defun google-translate--get-b-d1 ()
    ;; TKK='427110.1469889687'
    (list 427110 1469889687)))

You can use TKK='427110.1469889687', TKK='427116.3269864724' or other value.

SunDawning avatar Sep 24 '18 03:09 SunDawning

Same problem here. It has been working for months without a problem, but now i get google-translate--search-tkk: Failed to search TKK all the time. I tried to set google-translate--tkk-debug to true, but no second buffer with debug info appears.

Emacs 25.1.1; Google Translate (version): 0.11.14

A stubborn error in the Messages buffer:

 google-translate--search-tkk: Failed to search TKK

even if I change:

    (setq google-translate-base-url                                                                                            
          "https://translate.google.com/translate_a/single"                                                                    
          google-translate--tkk-url                                                                                            
          "https://translate.google.com/") 

0--key avatar Sep 24 '18 18:09 0--key

Same here.

jajpater avatar Sep 25 '18 08:09 jajpater

I had the same problems two days ago. My emacs version is 26.1

@SunDawning your fix work for me. Thanks you

(use-package google-translate
:ensure t
:config
(when (and (string-match "0.11.14"
(google-translate-version))
             (>= (time-to-seconds)
		 (time-to-seconds
                  (encode-time 0 0 0 23 9 2018))))
    (defun google-translate--get-b-d1 ()
      ;; TKK='427110.1469889687'
      (list 427110 1469889687))))

edurante avatar Sep 25 '18 11:09 edurante

@edurante Thanks for your workaround!

I also use use-package, and the below patch works for me. 😃

-:config
+:init

ybiquitous avatar Sep 26 '18 17:09 ybiquitous

I'm very sorry! The above patch in https://github.com/atykhonov/google-translate/issues/52#issuecomment-424796072 is my misunderstanding. 🙇 (:config is correct, NOT :init)

Also, I need this workaround using bind-keys* instead of :bind:

(use-package google-translate
  :config
  ;; ...
  ;; Workaround in https://github.com/atykhonov/google-translate/issues/52#issuecomment-424302439
  ;; ...

  ;; BEGIN: Workaround which I need
  (bind-keys*
    ("C-c t" . google-translate-at-point)
    ("C-c T" . google-translate-at-point-reverse))
  ;; :bind (("C-c t" . google-translate-at-point)
  ;;        ("C-c T" . google-translate-at-point-reverse))
  ;; END
  )

ybiquitous avatar Sep 26 '18 17:09 ybiquitous

@SunDawning it works very well! Thanks a lot! I'm preparing a patch based on the workaround.

atykhonov avatar Sep 26 '18 18:09 atykhonov

The v0.11.15 have been released with the fix. Please update. It works well. In a case of any issue please report here (the issue is not going to be closed while we have tkk).

All credit to @SunDawning.

Thank you all!

atykhonov avatar Sep 26 '18 19:09 atykhonov

The latest version works fine (no TKK error any more). I needed to restart emacs after re-installing google-translate.

jack836 avatar Sep 27 '18 01:09 jack836

Looks like the error is up again Search failed: ";TKK='", could someone, please, confirm? All worked just about a week ago.

Version: 0.11.15.

some-mthfka avatar Nov 09 '18 16:11 some-mthfka