You are not logged in.

#1 2016-05-24 23:44:20

peoro
Member
Registered: 2007-06-10
Posts: 67

Chromium doesn't translate pages

Hey guys!

When I visit a webpage in a foreign language Chromium asks me to translate it. Clicking on "Translate" doesn't work though.
This has been going on for at least a couple of years (Arch has been installed on this machine since I bought it... 2012?).

This happens with every user on my system: I just created a new one, and it's affected. It happens also in incognito and whether I sign in to Chromium or not makes no difference.

The other Google services all work: I can sign in to Chromium and it syncs my bookmarks etc.

I noticed that when I try to translate a webpage, I get the following errors in the Javascript console:

VM457:174 POST https://translate.googleapis.com/translate_a/t?anno=3&client=te_lib&format=html&v=1.0&key&logld=v34&sl=de&tl=en&tc=1&tk=261081.380791&mode=1 403 ()
VM457:174 POST https://translate.googleapis.com/translate_a/t?anno=3&client=te_lib&format=html&v=1.0&key&logld=v34&sl=de&tl=en&tc=2&tk=27166.417456&mode=1 403 ()

I looked at what happens on systems where the translation works: the big difference is that the `key` query parameter is missing on my system, and it's normal that translate gives 403 if the key is missing. If I request the same page, manually setting `key` to the value it has on a different system, the page succeeds, rather than giving me 403.
(i.e. here is the first of the two links I showed with the Google API keys of Chromium for Archlinux: https://translate.googleapis.com/transl … 456&mode=1 ).

This makes me think that the Chromium keys are missing on my system, although `chromium` has been installed from the official repos (it's currently 50.0.2661.102-1), syncing bookmarks works fine, and everything installed from the `chromium` package matches what's installed on other systems:

$ for file in $(pacman -Qlq chromium); do [ -f $file ] && echo $file; done | xargs cat | md5sum
0ed2515d1d3146c2f5eede3028db5732  -

Any ideas?

Offline

#2 2017-05-05 14:39:24

srand
Member
Registered: 2017-05-05
Posts: 1

Re: Chromium doesn't translate pages

I hope this qualifies as an acceptable necro-bump, at least I haven't found a more recent thread and I'm surprised this
issue hasn't affected more people.
After finally spending a few hours actually looking into this issue, as it's been annoying me for several years now, I found
the culprit (at least for me) to be FS#44735.

This took me longer to figure out than I'm happy to admit. I went from reading through Chrome Developer documentation
about API keys, to suspecting a possible packaging error, to reading through the Chromium packaging on other distros, to
reading through Chromium source code, to finally noticing that the API key Chromium was using didn't match the API key
provided to Arch Linux, to realising it is actually my own private API key that's being used in Chromium.

So, long story short, I installed minitube back in 2016 and as requested, provided it with a private API key of mine
in /etc/profile.d/minitube.sh and forgetting all about it. Unfortunately, having this environment variable set overrides
the key provided for Arch Linux in Chromium. Just installing minitube exports GOOGLE_API_KEY="", which results in 403
errors (empty key) for those who just installed minitube but never provided an API key, or 403 errors (unprivileged key)
for people like me who provided their own private API keys.

Translate being broken in Chromium is just the most obvious side-effect I happened to notice. So, if you happen to have
issues with Chromium features which rely on Google APIs, check the developer console for 403 errors. Then check if you
have minitube installed. Then check if you have any stray environment variables exported, such as GOOGLE_API_KEY,
GOOGLE_DEFAULT_CLIENT_ID or GOOGLE_DEFAULT_CLIENT_SECRET.

$ unset GOOGLE_API_KEY
$ unset GOOGLE_DEFAULT_CLIENT_ID
$ unset GOOGLE_DEFAULT_CLIENT_SECRET
$ chromium

Last edited by srand (2017-05-05 14:51:24)

Offline

Board footer

Powered by FluxBB