google-translate-api
google-translate-api copied to clipboard
China doesn't work: Default URL banned, no proxy support, alternate URL not working
In China the regular page is banned, normally we have to use translate.google.cn instead.
No URL spec option There doesn't seem to be an option to redirect the queries to a new URL (China's is probably the only meaningful one out there).
I tried manually modifying the URL in my version of the library but it didn't work. Unfamiliar with node debugging so unsure how to get low level HTTP response information. However, this is what it looks like from a browser.
No proxy option
I looked for a proxy option but apparently that doesn't exit either. I also tried setting the standard unix environment variables: proxy
, http_proxy
, https_proxy
, proxy_all
, etc. but none appeared to take effect.
you can change the request url translate.google.com
to translate.google.cn
. or you can install the package google-translate-api-cn by npm install --save google-translate-api-cn
.
This has been fixed in a better manner in https://github.com/vitalets/google-translate-api as of the writing of this comment.
Released yesterday @vitalets/google-translate-api where with help of @coltongit we can use custom tld
for google translate host:
const translate = require('@vitalets/google-translate-api');
translate('Ik spreek Engels', {to: 'en', tld: 'cn'}).then(res => { ... });
// sends request to translate.google.cn