add chinese translations

pull/379/head
Foolin 6 years ago
parent 801b2c40bc
commit d1a82a6cdc
  1. 16
      translations/zh/zh.go
  2. 22
      translations/zh/zh_test.go

@ -33,7 +33,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
tag: "len", tag: "len",
customRegisFunc: func(ut ut.Translator) (err error) { customRegisFunc: func(ut ut.Translator) (err error) {
if err = ut.Add("len-string", "{0}长度必须{1}", false); err != nil { if err = ut.Add("len-string", "{0}长度必须{1}", false); err != nil {
return return
} }
@ -124,7 +124,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
tag: "min", tag: "min",
customRegisFunc: func(ut ut.Translator) (err error) { customRegisFunc: func(ut ut.Translator) (err error) {
if err = ut.Add("min-string", "{0}长度最小只能为{1}", false); err != nil { if err = ut.Add("min-string", "{0}长度必须至少为{1}", false); err != nil {
return return
} }
@ -136,7 +136,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return return
} }
if err = ut.Add("min-number", "{0}必须大于或等于{1}", false); err != nil { if err = ut.Add("min-number", "{0}最小只能为{1}", false); err != nil {
return return
} }
@ -215,7 +215,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
tag: "max", tag: "max",
customRegisFunc: func(ut ut.Translator) (err error) { customRegisFunc: func(ut ut.Translator) (err error) {
if err = ut.Add("max-string", "{0}长度最大只能为{1}", false); err != nil { if err = ut.Add("max-string", "{0}长度不能超过{1}", false); err != nil {
return return
} }
@ -231,7 +231,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return return
} }
if err = ut.Add("max-items", "{0}包含最大数量为{1}", false); err != nil { if err = ut.Add("max-items", "{0}最多只能包含{1}", false); err != nil {
return return
} }
//if err = ut.AddCardinal("max-items-item", "{0}项", locales.PluralRuleOne, false); err != nil { //if err = ut.AddCardinal("max-items-item", "{0}项", locales.PluralRuleOne, false); err != nil {
@ -352,7 +352,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return return
} }
if err = ut.Add("lt-items", "{0}包含最小数量为{1}", false); err != nil { if err = ut.Add("lt-items", "{0}必须包含少于{1}", false); err != nil {
return return
} }
@ -484,7 +484,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return return
} }
if err = ut.Add("lte-datetime", "{0}小于或等于当前日期和时间", false); err != nil { if err = ut.Add("lte-datetime", "{0}必须小于或等于当前日期和时间", false); err != nil {
return return
} }
@ -1296,7 +1296,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
}, },
{ {
tag: "oneof", tag: "oneof",
translation: "{0}必须是[{1}]的其中一个", translation: "{0}必须是[{1}]的一个",
override: false, override: false,
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { customTransFunc: func(ut ut.Translator, fe validator.FieldError) string {
s, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) s, err := ut.T(fe.Tag(), fe.Field(), fe.Param())

@ -452,7 +452,7 @@ func TestTranslations(t *testing.T) {
}, },
{ {
ns: "Test.GteMultiple", ns: "Test.GteMultiple",
expected: "GteMultiple至少包含2项", expected: "GteMultiple必须至少包含2项",
}, },
{ {
ns: "Test.GteTime", ns: "Test.GteTime",
@ -500,7 +500,7 @@ func TestTranslations(t *testing.T) {
}, },
{ {
ns: "Test.LtMultiple", ns: "Test.LtMultiple",
expected: "LtMultiple只能包含小于2项", expected: "LtMultiple必须包含少于2项",
}, },
{ {
ns: "Test.LtTime", ns: "Test.LtTime",
@ -508,15 +508,15 @@ func TestTranslations(t *testing.T) {
}, },
{ {
ns: "Test.NeString", ns: "Test.NeString",
expected: "NeString不应该等于 ", expected: "NeString不能等于",
}, },
{ {
ns: "Test.NeNumber", ns: "Test.NeNumber",
expected: "NeNumber不应该等于0.00", expected: "NeNumber不等于0.00",
}, },
{ {
ns: "Test.NeMultiple", ns: "Test.NeMultiple",
expected: "NeMultiple不应该等于0", expected: "NeMultiple不等于0",
}, },
{ {
ns: "Test.EqString", ns: "Test.EqString",
@ -552,7 +552,7 @@ func TestTranslations(t *testing.T) {
}, },
{ {
ns: "Test.MinMultiple", ns: "Test.MinMultiple",
expected: "MinMultiple至少包含7项", expected: "MinMultiple必须至少包含7项",
}, },
{ {
ns: "Test.LenString", ns: "Test.LenString",
@ -568,15 +568,15 @@ func TestTranslations(t *testing.T) {
}, },
{ {
ns: "Test.RequiredString", ns: "Test.RequiredString",
expected: "RequiredString是一个必填的字段", expected: "RequiredString为必填字段",
}, },
{ {
ns: "Test.RequiredNumber", ns: "Test.RequiredNumber",
expected: "RequiredNumber是一个必填的字段", expected: "RequiredNumber为必填字段",
}, },
{ {
ns: "Test.RequiredMultiple", ns: "Test.RequiredMultiple",
expected: "RequiredMultiple是一个必填的字段", expected: "RequiredMultiple为必填字段",
}, },
{ {
ns: "Test.StrPtrMinLen", ns: "Test.StrPtrMinLen",
@ -584,7 +584,7 @@ func TestTranslations(t *testing.T) {
}, },
{ {
ns: "Test.StrPtrMaxLen", ns: "Test.StrPtrMaxLen",
expected: "StrPtrMaxLen长度必须最大为1个字符", expected: "StrPtrMaxLen长度不能超过1个字符",
}, },
{ {
ns: "Test.StrPtrLen", ns: "Test.StrPtrLen",
@ -596,7 +596,7 @@ func TestTranslations(t *testing.T) {
}, },
{ {
ns: "Test.StrPtrLte", ns: "Test.StrPtrLte",
expected: "StrPtrLte长度必须最大为1个字符", expected: "StrPtrLte长度不能超过1个字符",
}, },
{ {
ns: "Test.StrPtrGt", ns: "Test.StrPtrGt",

Loading…
Cancel
Save