Просмотр исходного кода

feat: Add Korean translations validator (#168)

lejianwen месяцев назад: 10
Родитель
Сommit
3ef4454c05
2 измененных файлов с 9 добавлено и 8 удалено
  1. 2 2
      global/apiValidator.go
  2. 7 6
      go.mod

+ 2 - 2
global/apiValidator.go

@@ -14,6 +14,7 @@ import (
14
 	en_translations "github.com/go-playground/validator/v10/translations/en"
14
 	en_translations "github.com/go-playground/validator/v10/translations/en"
15
 	es_translations "github.com/go-playground/validator/v10/translations/es"
15
 	es_translations "github.com/go-playground/validator/v10/translations/es"
16
 	fr_translations "github.com/go-playground/validator/v10/translations/fr"
16
 	fr_translations "github.com/go-playground/validator/v10/translations/fr"
17
+	ko_translations "github.com/go-playground/validator/v10/translations/ko"
17
 	ru_translations "github.com/go-playground/validator/v10/translations/ru"
18
 	ru_translations "github.com/go-playground/validator/v10/translations/ru"
18
 	zh_translations "github.com/go-playground/validator/v10/translations/zh"
19
 	zh_translations "github.com/go-playground/validator/v10/translations/zh"
19
 	zh_tw_translations "github.com/go-playground/validator/v10/translations/zh_tw"
20
 	zh_tw_translations "github.com/go-playground/validator/v10/translations/zh_tw"
@@ -51,8 +52,7 @@ func ApiInitValidator() {
51
 		panic(err)
52
 		panic(err)
52
 	}
53
 	}
53
 
54
 
54
-	//validate没有ko的翻译,使用zh的翻译
55
-	err = zh_translations.RegisterDefaultTranslations(validate, koTrans)
55
+	err = ko_translations.RegisterDefaultTranslations(validate, koTrans)
56
 	if err != nil {
56
 	if err != nil {
57
 		panic(err)
57
 		panic(err)
58
 	}
58
 	}

+ 7 - 6
go.mod

@@ -10,7 +10,7 @@ require (
10
 	github.com/gin-gonic/gin v1.9.0
10
 	github.com/gin-gonic/gin v1.9.0
11
 	github.com/go-playground/locales v0.14.1
11
 	github.com/go-playground/locales v0.14.1
12
 	github.com/go-playground/universal-translator v0.18.1
12
 	github.com/go-playground/universal-translator v0.18.1
13
-	github.com/go-playground/validator/v10 v10.11.2
13
+	github.com/go-playground/validator/v10 v10.26.0
14
 	github.com/go-redis/redis/v8 v8.11.4
14
 	github.com/go-redis/redis/v8 v8.11.4
15
 	github.com/golang-jwt/jwt/v5 v5.2.1
15
 	github.com/golang-jwt/jwt/v5 v5.2.1
16
 	github.com/google/uuid v1.6.0
16
 	github.com/google/uuid v1.6.0
@@ -22,7 +22,7 @@ require (
22
 	github.com/swaggo/gin-swagger v1.6.0
22
 	github.com/swaggo/gin-swagger v1.6.0
23
 	github.com/swaggo/swag v1.16.3
23
 	github.com/swaggo/swag v1.16.3
24
 	golang.org/x/oauth2 v0.23.0
24
 	golang.org/x/oauth2 v0.23.0
25
-	golang.org/x/text v0.21.0
25
+	golang.org/x/text v0.22.0
26
 	gorm.io/driver/mysql v1.5.7
26
 	gorm.io/driver/mysql v1.5.7
27
 	gorm.io/driver/sqlite v1.5.6
27
 	gorm.io/driver/sqlite v1.5.6
28
 	gorm.io/gorm v1.25.7
28
 	gorm.io/gorm v1.25.7
@@ -38,6 +38,7 @@ require (
38
 	github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
38
 	github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
39
 	github.com/coreos/go-oidc/v3 v3.12.0 // indirect
39
 	github.com/coreos/go-oidc/v3 v3.12.0 // indirect
40
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
40
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
41
+	github.com/gabriel-vasile/mimetype v1.4.8 // indirect
41
 	github.com/gin-contrib/sse v0.1.0 // indirect
42
 	github.com/gin-contrib/sse v0.1.0 // indirect
42
 	github.com/go-asn1-ber/asn1-ber v1.5.7 // indirect
43
 	github.com/go-asn1-ber/asn1-ber v1.5.7 // indirect
43
 	github.com/go-jose/go-jose/v4 v4.0.2 // indirect
44
 	github.com/go-jose/go-jose/v4 v4.0.2 // indirect
@@ -56,7 +57,7 @@ require (
56
 	github.com/josharian/intern v1.0.0 // indirect
57
 	github.com/josharian/intern v1.0.0 // indirect
57
 	github.com/json-iterator/go v1.1.12 // indirect
58
 	github.com/json-iterator/go v1.1.12 // indirect
58
 	github.com/klauspost/cpuid/v2 v2.0.9 // indirect
59
 	github.com/klauspost/cpuid/v2 v2.0.9 // indirect
59
-	github.com/leodido/go-urn v1.2.1 // indirect
60
+	github.com/leodido/go-urn v1.4.0 // indirect
60
 	github.com/magiconair/properties v1.8.5 // indirect
61
 	github.com/magiconair/properties v1.8.5 // indirect
61
 	github.com/mailru/easyjson v0.7.7 // indirect
62
 	github.com/mailru/easyjson v0.7.7 // indirect
62
 	github.com/mattn/go-isatty v0.0.17 // indirect
63
 	github.com/mattn/go-isatty v0.0.17 // indirect
@@ -75,10 +76,10 @@ require (
75
 	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
76
 	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
76
 	github.com/ugorji/go/codec v1.2.9 // indirect
77
 	github.com/ugorji/go/codec v1.2.9 // indirect
77
 	golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
78
 	golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
78
-	golang.org/x/crypto v0.31.0 // indirect
79
+	golang.org/x/crypto v0.33.0 // indirect
79
 	golang.org/x/image v0.13.0 // indirect
80
 	golang.org/x/image v0.13.0 // indirect
80
-	golang.org/x/net v0.33.0 // indirect
81
-	golang.org/x/sys v0.28.0 // indirect
81
+	golang.org/x/net v0.34.0 // indirect
82
+	golang.org/x/sys v0.30.0 // indirect
82
 	golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
83
 	golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
83
 	google.golang.org/protobuf v1.33.0 // indirect
84
 	google.golang.org/protobuf v1.33.0 // indirect
84
 	gopkg.in/ini.v1 v1.63.2 // indirect
85
 	gopkg.in/ini.v1 v1.63.2 // indirect