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

China doesn't work: Default URL banned, no proxy support, alternate URL not working #60

Open
globalcitizen opened this issue Mar 19, 2018 · 3 comments · Fixed by vitalets/google-translate-api#7

Comments

@globalcitizen
Copy link

globalcitizen commented Mar 19, 2018

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.

google-translate-china

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.

@globalcitizen globalcitizen changed the title No proxy support China doesn't work: Default URL banned, no proxy support, alternate URL not working Mar 19, 2018
@mack-wang
Copy link

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.

@rawr51919
Copy link

This has been fixed in a better manner in https://github.com/vitalets/google-translate-api as of the writing of this comment.

@vitalets
Copy link

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

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

Successfully merging a pull request may close this issue.

4 participants