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

问题咨询 #17

Open
yangql176 opened this issue May 14, 2024 · 2 comments
Open

问题咨询 #17

yangql176 opened this issue May 14, 2024 · 2 comments

Comments

@yangql176
Copy link

嗨 您好,我在调研项目国际化的过程中看到了您的vscode插件,有个问题想要咨询您下:

我看您的插件里用到了Google翻译 我发现好像是不用任何appKey就可以直接使用的,我本身也有梯子 所以您的插件本身使用没有问题,但我在本地用和您一样的引入和用法却总是不能用,总是在报FetchError: Invalid response body while trying to fetch https://translate.google.com/translate_a/single?client=at&dt=t&dt=rm&dj=1: read ECONNRESET

非常非常偶尔才可以正确输出翻译内容
想问下这个是怎么回事呢

@Kerinlin
Copy link
Owner

嗨 您好,我在调研项目国际化的过程中看到了您的vscode插件,有个问题想要咨询您下:

我看您的插件里用到了Google翻译 我发现好像是不用任何appKey就可以直接使用的,我本身也有梯子 所以您的插件本身使用没有问题,但我在本地用和您一样的引入和用法却总是不能用,总是在报FetchError: Invalid response body while trying to fetch https://translate.google.com/translate_a/single?client=at&dt=t&dt=rm&dj=1: read ECONNRESET

非常非常偶尔才可以正确输出翻译内容 想问下这个是怎么回事呢

应该是谷歌这边的限制,限制不能发送太多请求,可参考一下库这边的处理,https://github.com/vitalets/google-translate-api?tab=readme-ov-file#limits

@Kerinlin
Copy link
Owner

import { translate } from '@vitalets/google-translate-api';
import { HttpProxyAgent } from 'http-proxy-agent';

const agent = new HttpProxyAgent('http://212.107.29.43:80');
const res = await translate('Привет, мир!', {
  to: 'en',
  fetchOptions: { agent },
});

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

No branches or pull requests

2 participants