egg-validate icon indicating copy to clipboard operation
egg-validate copied to clipboard

feat: support i18n and rules config

Open runfan opened this issue 6 years ago • 11 comments

Checklist
  • [x] npm test passes
  • [x] documentation is changed or added
Affected core subsystem(s)

错误信息输出支持 eggjs 中的 i18n

Description of change

parameter.translate 实现,并且使用 gettext 支持 app.validate 去掉 增加在 config.default 中配置 rules

runfan avatar Nov 08 '17 23:11 runfan

Codecov Report

Merging #7 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #7   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      1    -2     
  Lines           9     14    +5     
=====================================
+ Hits            9     14    +5
Impacted Files Coverage Δ
app/extend/context.js 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5b7ade0...07966d3. Read the comment docs.

codecov-io avatar Nov 08 '17 23:11 codecov-io

补充了 context 的测试

runfan avatar Nov 13 '17 10:11 runfan

中文部分的测试已经补充

runfan avatar Nov 13 '17 11:11 runfan

我把依赖包升级了一下,测试代码已经改过来了。 测试时发现升级后还是无法获取到 app.gettext

runfan avatar Nov 15 '17 02:11 runfan

i18n 没有注册 app.gettext 吧,是在 ctx 上的

atian25 avatar Nov 15 '17 03:11 atian25

嗯,所以 validator 目前还是得绑定在 context 中而不是 app 中。这种情况下 this.validator.addRule这个用法好像意义不大。而且只能在 context 中

runfan avatar Nov 15 '17 08:11 runfan

嗯,先这样吧,反正原来也是有 addRule 的,加载文件的后面有需要再另起 PR。

cc @eggjs/core 也 Review 下?

atian25 avatar Nov 15 '17 09:11 atian25

喔噢

发自我的 iPhone

在 2017年11月16日,16:40,cwfan [email protected] 写道:

@runfan commented on this pull request.

In config/locales/zh-CN.js:

@@ -0,0 +1,27 @@ +'use strict'; egg config 下面的文件是会合并的不是吗?我是希望这些翻译直接做为默认的中文翻译放到项目中:)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

atian25 avatar Nov 16 '17 11:11 atian25

那么,我关闭这个 PR 了

runfan avatar Nov 17 '17 07:11 runfan

先留着吧,回头我在另一个 PR 中自动 close 也行。 不急吧?在搞 2.0 ing

atian25 avatar Nov 17 '17 07:11 atian25

@atian25 @dead-horse @runfan any progress on this?

JoaoCnh avatar Nov 13 '18 23:11 JoaoCnh