-
Notifications
You must be signed in to change notification settings - Fork 383
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
Niutrans support #222
Conversation
There was a problem hiding this 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
你好,请提交 PR 到 dev 分支,这里有说明 https://github.com/tisfeng/Easydict#%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97 |
Easydict/.DS_Store
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我记得项目中有 .gitignore,为什么 .DS_Store 文件还会被提交上来?
Easydict/App/Localizable.xcstrings
Outdated
"en" : { | ||
"stringUnit" : { | ||
"state" : "needs_review", | ||
"value" : "" |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
return self; | ||
} | ||
|
||
- (EZWebViewTranslator *)webViewTranslator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个属性是没必要的,我还看到一些其他与当前功能无关的代码。
如果是因为你不熟悉 objc ,这部份多余的代码稍后我可以帮你去掉。
Easydict/App/EZConst.h
Outdated
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
默认设置网络超时时间为 15s,为什么要改这个值?
There was a problem hiding this 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"; |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 提供一个默认值,这样既能方便新用户使用,也能提升小牛翻译的竞争力。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参考这里 彩云小译 就提供了一个官方的 Token ,当然,为了避免滥用,可以为这个 key 做一些设置,比如限制每日最大免费字符数量。
如果确定了,可以通过邮件发给我,我在应用内简单加密处理一下。
非常感谢您的建议,我这边第一次使用objc,都是摸索着来。 |
你可以在本地拉取最新的 dev 分支代码,将你这个 PR 的代码 rebase dev |
初步支持小牛翻译 #211
APIkey配置方法与DeepL相同:
easydict://writeKeyValue?EZNiuTransAuthKey=xxx