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