@@ -7,55 +7,193 @@ import (
7
7
type Localizer interface {
8
8
// Get the translation for the given text in the given context.
9
9
// If no translation is found, an empty string should be returned.
10
- Localizef (ctx context.Context , txt string , args ... any ) string
10
+ Localizef (ctx context.Context , key LocalizationKey , args ... any ) string
11
11
}
12
12
13
- // Translation constants
14
- const (
15
- TxtSuccess = "success"
13
+ type LocalizationKey struct {
14
+ ID string
15
+ Default string
16
+ }
17
+
18
+ var (
19
+ TxtSuccess = LocalizationKey {
20
+ ID : "Success" ,
21
+ Default : "success" ,
22
+ }
16
23
17
24
// Used in the auth module
18
- TxtInvalidCredentials = "Invalid Credentials"
19
- TxtAuthFailed = "Please login"
25
+ TxtInvalidCredentials = LocalizationKey {
26
+ ID : "InvalidCredentials" ,
27
+ Default : "Invalid Credentials" ,
28
+ }
29
+ TxtAuthFailed = LocalizationKey {
30
+ ID : "AuthFailed" ,
31
+ Default : "Please login" ,
32
+ }
20
33
21
34
// Used in the register module
22
- TxtUserAlreadyExists = "User already exists"
23
- TxtRegisteredAndLoggedIn = "Account successfully created, you are now logged in"
35
+ TxtUserAlreadyExists = LocalizationKey {
36
+ ID : "UserAlreadyExists" ,
37
+ Default : "User already exists" ,
38
+ }
39
+ TxtRegisteredAndLoggedIn = LocalizationKey {
40
+ ID : "RegisteredAndLoggedIn" ,
41
+ Default : "Account successfully created, you are now logged in" ,
42
+ }
24
43
25
44
// Used in the confirm module
26
- TxtConfirmYourAccount = "Please verify your account, an e-mail has been sent to you."
27
- TxtAccountNotConfirmed = "Your account has not been confirmed, please check your e-mail."
28
- TxtInvalidConfirmToken = "Your confirmation token is invalid."
29
- TxtConfrimationSuccess = "You have successfully confirmed your account."
30
- TxtConfirmEmailSubject = "Confirm New Account"
45
+ TxtConfirmYourAccount = LocalizationKey {
46
+ ID : "ConfirmYourAccount" ,
47
+ Default : "Please verify your account, an e-mail has been sent to you." ,
48
+ }
49
+ TxtAccountNotConfirmed = LocalizationKey {
50
+ ID : "AccountNotConfirmed" ,
51
+ Default : "Your account has not been confirmed, please check your e-mail." ,
52
+ }
53
+ TxtInvalidConfirmToken = LocalizationKey {
54
+ ID : "InvalidConfirmToken" ,
55
+ Default : "Your confirmation token is invalid." ,
56
+ }
57
+ TxtConfrimationSuccess = LocalizationKey {
58
+ ID : "ConfrimationSuccess" ,
59
+ Default : "You have successfully confirmed your account." ,
60
+ }
61
+ TxtConfirmEmailSubject = LocalizationKey {
62
+ ID : "ConfirmEmailSubject" ,
63
+ Default : "Confirm New Account" ,
64
+ }
31
65
32
66
// Used in the lock module
33
- TxtLocked = "Your account has been locked, please contact the administrator."
67
+ TxtLocked = LocalizationKey {
68
+ ID : "Locked" ,
69
+ Default : "Your account has been locked, please contact the administrator." ,
70
+ }
34
71
35
72
// Used in the logout module
36
- TxtLoggedOut = "You have been logged out"
73
+ TxtLoggedOut = LocalizationKey {
74
+ ID : "LoggedOut" ,
75
+ Default : "You have been logged out" ,
76
+ }
37
77
38
78
// Used in the oauth2 module
39
- TxtOAuth2LoginOK = "Logged in successfully with %s."
40
- TxtOAuth2LoginNotOK = "%s login cancelled or failed"
79
+ TxtOAuth2LoginOK = LocalizationKey {
80
+ ID : "OAuth2LoginOK" ,
81
+ Default : "Logged in successfully with %s." ,
82
+ }
83
+ TxtOAuth2LoginNotOK = LocalizationKey {
84
+ ID : "OAuth2LoginNotOK" ,
85
+ Default : "%s login cancelled or failed" ,
86
+ }
41
87
42
88
// Used in the recover module
43
- TxtRecoverInitiateSuccessFlash = "An email has been sent to you with further instructions on how to reset your password."
44
- TxtPasswordResetEmailSubject = "Password Reset"
45
- TxtRecoverSuccessMsg = "Successfully updated password"
46
- TxtRecoverAndLoginSuccessMsg = "Successfully updated password and logged in"
89
+ TxtRecoverInitiateSuccessFlash = LocalizationKey {
90
+ ID : "RecoverInitiateSuccessFlash" ,
91
+ Default : "An email has been sent to you with further instructions on how to reset your password." ,
92
+ }
93
+ TxtPasswordResetEmailSubject = LocalizationKey {
94
+ ID : "PasswordResetEmailSubject" ,
95
+ Default : "Password Reset" ,
96
+ }
97
+ TxtRecoverSuccessMsg = LocalizationKey {
98
+ ID : "RecoverSuccessMsg" ,
99
+ Default : "Successfully updated password" ,
100
+ }
101
+ TxtRecoverAndLoginSuccessMsg = LocalizationKey {
102
+ ID : "RecoverAndLoginSuccessMsg" ,
103
+ Default : "Successfully updated password and logged in" ,
104
+ }
47
105
48
106
// Used in the otp module
49
- TxtTooManyOTPs = "You cannot have more than %d one time passwords"
107
+ TxtTooManyOTPs = LocalizationKey {
108
+ ID : "TooManyOTPs" ,
109
+ Default : "You cannot have more than %d one time passwords" ,
110
+ }
50
111
51
112
// Used in the 2fa module
52
- TxtEmailVerifyTriggered = "An e-mail has been sent to confirm 2FA activation"
53
- TxtEmailVerifySubject = "Add 2FA to Account"
54
- TxtInvalid2FAVerificationToken = "Invalid 2FA email verification token"
55
- Txt2FAAuthorizationRequired = "You must first authorize adding 2fa by e-mail"
56
- TxtInvalid2FACode = "2FA code was invalid"
57
- TxtRepeated2FACode = "2FA code was previously used"
58
- TxtTOTP2FANotActive = "TOTP 2FA is not active"
59
- TxtSMSNumberRequired = "You must provide a phone number"
60
- TxtSMSWaitToResend = "Please wait a few moments before resending the SMS code"
113
+ TxtEmailVerifyTriggered = LocalizationKey {
114
+ ID : "EmailVerifyTriggered" ,
115
+ Default : "An e-mail has been sent to confirm 2FA activation" ,
116
+ }
117
+ TxtEmailVerifySubject = LocalizationKey {
118
+ ID : "EmailVerifySubject" ,
119
+ Default : "Add 2FA to Account" ,
120
+ }
121
+ TxtInvalid2FAVerificationToken = LocalizationKey {
122
+ ID : "Invalid2FAVerificationToken" ,
123
+ Default : "Invalid 2FA email verification token" ,
124
+ }
125
+ Txt2FAAuthorizationRequired = LocalizationKey {
126
+ ID : "2FAAuthorizationRequired" ,
127
+ Default : "You must first authorize adding 2fa by e-mail" ,
128
+ }
129
+ TxtInvalid2FACode = LocalizationKey {
130
+ ID : "Invalid2FACode" ,
131
+ Default : "2FA code was invalid" ,
132
+ }
133
+ TxtRepeated2FACode = LocalizationKey {
134
+ ID : "Repeated2FACode" ,
135
+ Default : "2FA code was previously used" ,
136
+ }
137
+ TxtTOTP2FANotActive = LocalizationKey {
138
+ ID : "TOTP2FANotActive" ,
139
+ Default : "TOTP 2FA is not active" ,
140
+ }
141
+ TxtSMSNumberRequired = LocalizationKey {
142
+ ID : "SMSNumberRequired" ,
143
+ Default : "You must provide a phone number" ,
144
+ }
145
+ TxtSMSWaitToResend = LocalizationKey {
146
+ ID : "SMSWaitToResend" ,
147
+ Default : "Please wait a few moments before resending the SMS code" ,
148
+ }
61
149
)
150
+
151
+ // // Translation constants
152
+ // const (
153
+ // TxtSuccess = "success"
154
+ //
155
+ // // Used in the auth module
156
+ // TxtInvalidCredentials = "Invalid Credentials"
157
+ // TxtAuthFailed = "Please login"
158
+ //
159
+ // // Used in the register module
160
+ // TxtUserAlreadyExists = "User already exists"
161
+ // TxtRegisteredAndLoggedIn = "Account successfully created, you are now logged in"
162
+ //
163
+ // // Used in the confirm module
164
+ // TxtConfirmYourAccount = "Please verify your account, an e-mail has been sent to you."
165
+ // TxtAccountNotConfirmed = "Your account has not been confirmed, please check your e-mail."
166
+ // TxtInvalidConfirmToken = "Your confirmation token is invalid."
167
+ // TxtConfrimationSuccess = "You have successfully confirmed your account."
168
+ // TxtConfirmEmailSubject = "Confirm New Account"
169
+ //
170
+ // // Used in the lock module
171
+ // TxtLocked = "Your account has been locked, please contact the administrator."
172
+ //
173
+ // // Used in the logout module
174
+ // TxtLoggedOut = "You have been logged out"
175
+ //
176
+ // // Used in the oauth2 module
177
+ // TxtOAuth2LoginOK = "Logged in successfully with %s."
178
+ // TxtOAuth2LoginNotOK = "%s login cancelled or failed"
179
+ //
180
+ // // Used in the recover module
181
+ // TxtRecoverInitiateSuccessFlash = "An email has been sent to you with further instructions on how to reset your password."
182
+ // TxtPasswordResetEmailSubject = "Password Reset"
183
+ // TxtRecoverSuccessMsg = "Successfully updated password"
184
+ // TxtRecoverAndLoginSuccessMsg = "Successfully updated password and logged in"
185
+ //
186
+ // // Used in the otp module
187
+ // TxtTooManyOTPs = "You cannot have more than %d one time passwords"
188
+ //
189
+ // // Used in the 2fa module
190
+ // TxtEmailVerifyTriggered = "An e-mail has been sent to confirm 2FA activation"
191
+ // TxtEmailVerifySubject = "Add 2FA to Account"
192
+ // TxtInvalid2FAVerificationToken = "Invalid 2FA email verification token"
193
+ // Txt2FAAuthorizationRequired = "You must first authorize adding 2fa by e-mail"
194
+ // TxtInvalid2FACode = "2FA code was invalid"
195
+ // TxtRepeated2FACode = "2FA code was previously used"
196
+ // TxtTOTP2FANotActive = "TOTP 2FA is not active"
197
+ // TxtSMSNumberRequired = "You must provide a phone number"
198
+ // TxtSMSWaitToResend = "Please wait a few moments before resending the SMS code"
199
+ // )
0 commit comments