add it_IT translation (#694)

pull/936/head
mrkongo 3 years ago committed by GitHub
parent 7fa836dc0a
commit 39aa2e3a27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      translations/it/it.go
  2. 9
      translations/it/it_test.go

@ -1,4 +1,4 @@
package en package it
import ( import (
"fmt" "fmt"
@ -28,6 +28,11 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
translation: "{0} è un campo obbligatorio", translation: "{0} è un campo obbligatorio",
override: false, override: false,
}, },
{
tag: "required_without",
translation: "{0} è un campo obbligatorio",
override: false,
},
{ {
tag: "len", tag: "len",
customRegisFunc: func(ut ut.Translator) (err error) { customRegisFunc: func(ut ut.Translator) (err error) {
@ -119,6 +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} deve essere lungo almeno {1}", false); err != nil { if err = ut.Add("min-string", "{0} deve essere lungo almeno {1}", false); err != nil {
return return
} }
@ -150,6 +156,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
}, },
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { customTransFunc: func(ut ut.Translator, fe validator.FieldError) string {
var err error var err error
var t string var t string
var digits uint64 var digits uint64
@ -320,6 +327,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
} }
if err = ut.Add("lt-number", "{0} deve essere minore di {1}", false); err != nil { if err = ut.Add("lt-number", "{0} deve essere minore di {1}", false); err != nil {
return return
} }
@ -424,6 +432,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
{ {
tag: "lte", tag: "lte",
customRegisFunc: func(ut ut.Translator) (err error) { customRegisFunc: func(ut ut.Translator) (err error) {
if err = ut.Add("lte-string", "{0} deve essere lungo al massimo {1}", false); err != nil { if err = ut.Add("lte-string", "{0} deve essere lungo al massimo {1}", false); err != nil {
return return
} }
@ -459,6 +468,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return return
}, },
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { customTransFunc: func(ut ut.Translator, fe validator.FieldError) string {
var err error var err error
var t string var t string
var f64 float64 var f64 float64
@ -541,6 +551,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
{ {
tag: "gt", tag: "gt",
customRegisFunc: func(ut ut.Translator) (err error) { customRegisFunc: func(ut ut.Translator) (err error) {
if err = ut.Add("gt-string", "{0} deve essere lungo più di {1}", false); err != nil { if err = ut.Add("gt-string", "{0} deve essere lungo più di {1}", false); err != nil {
return return
} }
@ -576,6 +587,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return return
}, },
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { customTransFunc: func(ut ut.Translator, fe validator.FieldError) string {
var err error var err error
var t string var t string
var f64 float64 var f64 float64
@ -693,6 +705,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return return
}, },
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { customTransFunc: func(ut ut.Translator, fe validator.FieldError) string {
var err error var err error
var t string var t string
var f64 float64 var f64 float64
@ -1195,7 +1208,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
} }
for _, t := range translations { for _, t := range translations {
if t.customTransFunc != nil && t.customRegisFunc != nil { if t.customTransFunc != nil && t.customRegisFunc != nil {
err = v.RegisterTranslation(t.tag, trans, t.customRegisFunc, t.customTransFunc) err = v.RegisterTranslation(t.tag, trans, t.customRegisFunc, t.customTransFunc)
} else if t.customTransFunc != nil && t.customRegisFunc == nil { } else if t.customTransFunc != nil && t.customRegisFunc == nil {

@ -1,4 +1,4 @@
package en package it
import ( import (
"testing" "testing"
@ -11,9 +11,9 @@ import (
) )
func TestTranslations(t *testing.T) { func TestTranslations(t *testing.T) {
it := italian.New() ita := italian.New()
uni := ut.New(it, it) uni := ut.New(ita, ita)
trans, _ := uni.GetTranslator("en") trans, _ := uni.GetTranslator("it")
validate := validator.New() validate := validator.New()
@ -198,6 +198,7 @@ func TestTranslations(t *testing.T) {
test.LowercaseString = "ABCDEFG" test.LowercaseString = "ABCDEFG"
test.UppercaseString = "abcdefg" test.UppercaseString = "abcdefg"
test.StartsWithString = "hello" test.StartsWithString = "hello"
test.StartsNotWithString = "foo-hello" test.StartsNotWithString = "foo-hello"
test.EndsWithString = "hello" test.EndsWithString = "hello"

Loading…
Cancel
Save