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

Niutrans support #222

Closed
wants to merge 15 commits into from
Closed

Conversation

BigGuang97
Copy link
Contributor

初步支持小牛翻译 #211

APIkey配置方法与DeepL相同:
easydict://writeKeyValue?EZNiuTransAuthKey=xxx

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello BigGuang97, Thank you for your first PR contribution 🎉 BigGuang97

@tisfeng
Copy link
Owner

tisfeng commented Nov 15, 2023

你好,请提交 PR 到 dev 分支,这里有说明 https://github.com/tisfeng/Easydict#%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我记得项目中有 .gitignore,为什么 .DS_Store 文件还会被提交上来?

"en" : {
"stringUnit" : {
"state" : "needs_review",
"value" : ""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该需要一个“小牛翻译”的英文名字,你可以切到英文环境测试一下。

EZLanguageSerbian, @"sr",
EZLanguageCroatian, @"hr",
EZLanguageMongolian, @"mn",
EZLanguageHebrew, @"et",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个语言代码有问题,文档上显示希伯来语是 he,我没有仔细看,麻烦你一一校对一下。

https://niutrans.com/documents/contents/trans_text#languageList

image

return self;
}

- (EZWebViewTranslator *)webViewTranslator {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个属性是没必要的,我还看到一些其他与当前功能无关的代码。

如果是因为你不熟悉 objc ,这部份多余的代码稍后我可以帮你去掉。

@@ -39,7 +39,7 @@ static NSString *const EZUserAgent = @"Mozilla/5.0 (Linux; Android 6.0; Nexus 5
// ???: If value is not 0.2, it seems will block animation, because default animationResizeTime is 0.2 ?
static NSTimeInterval const EZUpdateTableViewRowHeightAnimationDuration = 0.2;

static NSTimeInterval const EZNetWorkTimeoutInterval = 15.0;
static NSTimeInterval const EZNetWorkTimeoutInterval = 150.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

默认设置网络超时时间为 15s,为什么要改这个值?

Copy link
Owner

@tisfeng tisfeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请修改代码后,提交 PR 到 dev 分支。

@@ -28,6 +28,7 @@ static NSString *const EZOpenAIModelKey = @"EZOpenAIModelKey";


static NSString *const EZDeepLAuthKey = @"EZDeepLAuthKey";
static NSString *const EZNiuTransAPIKey = @"EZNiuTransAPIKey";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我这里改了一下命名 EZNiuTransAuthKey --> EZNiuTransAPIKey

NSString *url = [NSString stringWithFormat:@"%@/NiuTransServer/translation", host];

NSDictionary *params = @{
@"apikey" : self.apiKey,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easydict 的最初设计是希望能开箱即用,目前大部份翻译服务也不需要用户手动设置 key,所以暂时还未提供界面方式配置 key (后面重写设置页时会添加配置页面,但还需要一段时间)。

鉴于命令方式配置 key 不太友好,且当前已内置了较多优质的翻译服务,建议可以为 apikey 提供一个默认值,这样既能方便新用户使用,也能提升小牛翻译的竞争力。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考这里 彩云小译 就提供了一个官方的 Token ,当然,为了避免滥用,可以为这个 key 做一些设置,比如限制每日最大免费字符数量。

如果确定了,可以通过邮件发给我,我在应用内简单加密处理一下。

@BigGuang97
Copy link
Contributor Author

非常感谢您的建议,我这边第一次使用objc,都是摸索着来。
您提出的这些问题我会做出修改并重新提交。
默认APIkey的问题我们这边讨论一下,邮件与您联系。

@tisfeng
Copy link
Owner

tisfeng commented Nov 16, 2023

你好,请关闭这个 PR,将修改后的代码重新提交 PR 到 dev 分支,目前这个 PR 提交到 main 分支,导致有很多冗余的代码变动,不方便 review 代码。

image

@tisfeng tisfeng closed this Nov 16, 2023
@tisfeng
Copy link
Owner

tisfeng commented Nov 16, 2023

你可以在本地拉取最新的 dev 分支代码,将你这个 PR 的代码 rebase dev

@BigGuang97 BigGuang97 mentioned this pull request Nov 17, 2023
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 this pull request may close these issues.

2 participants