jimmyGALLAND 1 год назад
Родитель
Сommit
9ebfd6de85
2 измененных файлов с 156 добавлено и 1 удалено
  1. 12 1
      global/apiValidator.go
  2. 144 0
      resources/i18n/fr.toml

+ 12 - 1
global/apiValidator.go

@@ -6,6 +6,7 @@ import (
6 6
 	"github.com/go-playground/locales/es"
7 7
 	"github.com/go-playground/locales/ko"
8 8
 	"github.com/go-playground/locales/ru"
9
+	"github.com/go-playground/locales/fr"
9 10
 	"github.com/go-playground/locales/zh_Hans_CN"
10 11
 
11 12
 	ut "github.com/go-playground/universal-translator"
@@ -14,6 +15,7 @@ import (
14 15
 	es_translations "github.com/go-playground/validator/v10/translations/es"
15 16
 	ru_translations "github.com/go-playground/validator/v10/translations/ru"
16 17
 	zh_translations "github.com/go-playground/validator/v10/translations/zh"
18
+	fr_translations "github.com/go-playground/validator/v10/translations/fr"
17 19
 	"reflect"
18 20
 )
19 21
 
@@ -26,14 +28,16 @@ func ApiInitValidator() {
26 28
 	koT := ko.New()
27 29
 	ruT := ru.New()
28 30
 	esT := es.New()
31
+	frT := fr.New()
29 32
 
30
-	uni := ut.New(enT, cn, koT, ruT, esT)
33
+	uni := ut.New(enT, cn, koT, ruT, esT, frT)
31 34
 
32 35
 	enTrans, _ := uni.GetTranslator("en")
33 36
 	zhTrans, _ := uni.GetTranslator("zh_Hans_CN")
34 37
 	koTrans, _ := uni.GetTranslator("ko")
35 38
 	ruTrans, _ := uni.GetTranslator("ru")
36 39
 	esTrans, _ := uni.GetTranslator("es")
40
+	frTrans, _ := uni.GetTranslator("fr")
37 41
 
38 42
 	err := zh_translations.RegisterDefaultTranslations(validate, zhTrans)
39 43
 	if err != nil {
@@ -57,6 +61,10 @@ func ApiInitValidator() {
57 61
 	if err != nil {
58 62
 		panic(err)
59 63
 	}
64
+	err = fr_translations.RegisterDefaultTranslations(validate, frTrans)
65
+	if err != nil {
66
+		panic(err)
67
+	}
60 68
 
61 69
 	validate.RegisterTagNameFunc(func(field reflect.StructField) string {
62 70
 		label := field.Tag.Get("label")
@@ -126,6 +134,9 @@ func getTranslatorForLang(lang string) ut.Translator {
126 134
 	case "es":
127 135
 		trans, _ := Validator.UT.GetTranslator("es")
128 136
 		return trans
137
+	case "fr":
138
+		trans, _ := Validator.UT.GetTranslator("fr")
139
+		return trans
129 140
 	case "en":
130 141
 		fallthrough
131 142
 	default:

+ 144 - 0
resources/i18n/fr.toml

@@ -0,0 +1,144 @@
1
+[Test]
2
+description = "test"
3
+one = "test1 "
4
+other = "Test2 {{.P0}}"
5
+
6
+[ParamsError]
7
+description = "Params validation failed."
8
+one = "La validation des paramètres a échoué."
9
+other = "La validation des paramètres a échoué."
10
+
11
+[OperationFailed]
12
+description = "OperationFailed."
13
+one = "l'opération a échoué."
14
+other = "l'opération a échoué."
15
+
16
+[OperationSuccess]
17
+description = "OperationSuccess."
18
+one = "Opération réussie"
19
+other = "Opération réussie"
20
+
21
+[ItemExists]
22
+description = "Item already exists."
23
+one = "L'élément existe déjà."
24
+other = "L'élément existe déjà."
25
+
26
+[ItemNotFound]
27
+description = "Item not found."
28
+one = "Article introuvable."
29
+other = "Article introuvable."
30
+
31
+[NoAccess]
32
+description = "No access."
33
+one = "Aucun d'access."
34
+other = "Aucun d'access."
35
+
36
+[UsernameOrPasswordError]
37
+description = "Username or password error."
38
+one = "Nom d'utilisateur ou de mot de passe incorrect."
39
+other = "Nom d'utilisateur ou de mot de passe incorrect."
40
+
41
+[SystemError]
42
+description = "System error."
43
+one = "Erreur system."
44
+other = "Erreur system."
45
+
46
+[ConfigNotFound]
47
+description = "Config not found."
48
+one = "Configuration introuvable."
49
+other = "Configuration introuvable."
50
+
51
+[OauthExpired]
52
+description = "Oauth expired."
53
+one = "Oauth a expiré, veuillez réessayer."
54
+other = "Oauth a expiré, veuillez réessayer."
55
+
56
+[OauthFailed]
57
+description = "Oauth failed."
58
+one = "Oauth a échoué."
59
+other = "Oauth a échoué."
60
+
61
+[OauthHasBindOtherUser]
62
+description = "Oauth has bind other user."
63
+one = "Oauth a lié un autre utilisateur."
64
+other = "Oauth a lié un autre utilisateur."
65
+
66
+[ParamIsEmpty]
67
+description = "Param is empty."
68
+one = "{{.P0}} est vide."
69
+other = "{{.P0}} est vide."
70
+
71
+[BindFail]
72
+description = "Bind fail."
73
+one = "Échec de la liaison."
74
+other = "Échec de la liaison."
75
+
76
+[BindSuccess]
77
+description = "Bind success."
78
+one = "Succès de la liaison."
79
+other = "Succès de la liaison."
80
+
81
+[OauthHasBeenSuccess]
82
+description = "Oauth has been success."
83
+one = "Oauth a été réussi avec Succès."
84
+other = "Oauth a été réussi avec Succès."
85
+
86
+[OauthSuccess]
87
+description = "Oauth success."
88
+one = "Oauh réussi avec succès."
89
+other = "Oauh réussi avec succès."
90
+
91
+[OauthRegisterSuccess]
92
+description = "Oauth register success."
93
+one = "Succès de l'enregistrement Oauth."
94
+other = "Succès de l'enregistrement Oauth."
95
+
96
+[OauthRegisterFailed]
97
+description = "Oauth register failed."
98
+one = "L'inscription Oauth a échoué."
99
+other = "L'inscription Oauth a échoué."
100
+
101
+[GetOauthTokenError]
102
+description = "Get oauth token error."
103
+one = "Erreur de l'obtention du jeton oauth."
104
+other = "Erreur de l'obtention du jeton oauth."
105
+
106
+[GetOauthUserInfoError]
107
+description = "Get oauth user info error."
108
+one = "Erreur d'obtention d'informations sur l'utilisateur oauth."
109
+other = "Erreur d'obtention d'informations sur l'utilisateur oauth."
110
+
111
+[DecodeOauthUserInfoError]
112
+description = "Decode oauth user info error."
113
+one = "Erreur de décodage des informations utilisateur oauth."
114
+other = "Erreur de décodage des informations utilisateur oauth."
115
+
116
+[OldPasswordError]
117
+description = "Old password error."
118
+one = "Ancien mot de passe incorrect."
119
+other = "Ancien mot de passe incorrect."
120
+
121
+[DefaultGroup]
122
+description = "Default group"
123
+one = "Groupe Défaut"
124
+other = "Groupe Défaut"
125
+
126
+[ShareGroup]
127
+description = "Share group"
128
+one = "Groupe partagé"
129
+other = "Groupe partagé"
130
+
131
+[RegisterClosed]
132
+description = "Register closed."
133
+one = "Inscription fermée."
134
+other = "Inscription fermée."
135
+
136
+[CaptchaRequired]
137
+description = "Captcha required."
138
+one = "Captcha requis."
139
+other = "Captcha requis."
140
+
141
+[CaptchaError]
142
+description = "Captcha error."
143
+one = "Erreur de captcha."
144
+other = "Erreur de captcha."