Skip to content

Commit 57747bf

Browse files
authored
fix: add translations for sign in error [#143] (#145)
* fix: add translations for sign in error [#143] * fix: add missing userattribute localizations [#143]
1 parent c69ee50 commit 57747bf

File tree

6 files changed

+106
-2
lines changed

6 files changed

+106
-2
lines changed

packages/clerk_auth/lib/src/clerk_auth/auth.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,11 @@ class Auth {
337337

338338
// No matching sign-in sequence, reset loading state
339339
default:
340+
final status = signIn?.status ?? Status.unknown;
340341
addError(AuthError(
341342
code: AuthErrorCode.signInError,
342343
message: 'Unsupported sign in attempt: {arg}',
343-
argument: signIn?.status.toString() ?? '',
344+
argument: status.name,
344345
));
345346
}
346347

packages/clerk_auth/lib/src/models/status.dart

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class Status {
1616
/// fromJson factory for JsonSerializable
1717
factory Status.fromJson(String name) => Status(name: name);
1818

19+
/// unknown
20+
static const unknown = Status._('unknown');
21+
1922
/// abandoned
2023
static const abandoned = Status._('abandoned');
2124

@@ -53,6 +56,7 @@ class Status {
5356
static const failed = Status._('failed');
5457

5558
static final _values = <String, Status>{
59+
unknown.name: unknown,
5660
abandoned.name: abandoned,
5761
active.name: active,
5862
missingRequirements.name: missingRequirements,

packages/clerk_flutter/l10n/en.arb

+15
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
"alreadyHaveAnAccount": "Already have an account?",
3939
"anUppercaseLetter": "an UPPERCASE letter",
4040
"and": "and",
41+
"authenticatorApp": "authenticator app",
42+
"backupCode": "backup code",
4143
"cancel": "Cancel",
4244
"clickOnTheLinkThatSBeenSentToAndThenCheckBackHere": "Click on the link that‘s been sent to {identifier} and then check back here",
4345
"@clickOnTheLinkThatSBeenSentToAndThenCheckBackHere": {
@@ -73,6 +75,7 @@
7375
"enterTheCodeSentToYou": "Enter the code sent to you",
7476
"expired": "EXPIRED",
7577
"failed": "FAILED",
78+
"firstName": "first name",
7679
"invalidEmailAddress": "Invalid email address: {address}",
7780
"@invalidEmailAddress": {
7881
"placeholders": {
@@ -97,6 +100,7 @@
97100
}
98101
}
99102
},
103+
"lastName": "last name",
100104
"loading": "Loading…",
101105
"logo": "Logo",
102106
"missingRequirements": "MISSING REQUIREMENTS",
@@ -156,8 +160,10 @@
156160
"ok": "OK",
157161
"optional": "(optional)",
158162
"or": "or",
163+
"passkey": "passkey",
159164
"password": "Password",
160165
"passwordAndPasswordConfirmationMustMatch": "Password and password confirmation must match",
166+
"passwordConfirmation": "password confirmation",
161167
"passwordMatchError": "Password and password confirmation must match",
162168
"passwordMustBeSupplied": "A password must be supplied",
163169
"passwordRequires": "Password requires:",
@@ -174,6 +180,14 @@
174180
"signInByClickingALinkSentToYouByEmail": "Sign in by clicking a link sent to you by email",
175181
"signInByEnteringACodeSentToYouByEmail": "Sign in by entering a code sent to you by email",
176182
"signInByEnteringACodeSentToYouByTextMessage": "Sign in by entering a code sent to you by text message",
183+
"signInError": "Unsupported sign in attempt: {arg}",
184+
"@signInError": {
185+
"placeholders": {
186+
"arg": {
187+
"type": "String"
188+
}
189+
}
190+
},
177191
"signInTo": "Sign in to {name}",
178192
"@signInTo": {
179193
"placeholders": {
@@ -210,6 +224,7 @@
210224
"verified": "VERIFIED",
211225
"verifyYourEmailAddress": "Verify your email address",
212226
"verifyYourPhoneNumber": "Verify your phone number",
227+
"web3Wallet": "web3 wallet",
213228
"welcomeBackPleaseSignInToContinue": "Welcome back! Please sign in to continue",
214229
"welcomePleaseFillInTheDetailsToGetStarted": "Welcome! Please fill in the details to get started",
215230
"youNeedToAdd": "You need to add:"

packages/clerk_flutter/lib/src/generated/clerk_sdk_localizations.dart

+48
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,18 @@ abstract class ClerkSdkLocalizations {
178178
/// **'and'**
179179
String get and;
180180

181+
/// No description provided for @authenticatorApp.
182+
///
183+
/// In en, this message translates to:
184+
/// **'authenticator app'**
185+
String get authenticatorApp;
186+
187+
/// No description provided for @backupCode.
188+
///
189+
/// In en, this message translates to:
190+
/// **'backup code'**
191+
String get backupCode;
192+
181193
/// No description provided for @cancel.
182194
///
183195
/// In en, this message translates to:
@@ -262,6 +274,12 @@ abstract class ClerkSdkLocalizations {
262274
/// **'FAILED'**
263275
String get failed;
264276

277+
/// No description provided for @firstName.
278+
///
279+
/// In en, this message translates to:
280+
/// **'first name'**
281+
String get firstName;
282+
265283
/// No description provided for @invalidEmailAddress.
266284
///
267285
/// In en, this message translates to:
@@ -280,6 +298,12 @@ abstract class ClerkSdkLocalizations {
280298
/// **'JWT poorly formatted: {arg}'**
281299
String jwtPoorlyFormatted(String arg);
282300

301+
/// No description provided for @lastName.
302+
///
303+
/// In en, this message translates to:
304+
/// **'last name'**
305+
String get lastName;
306+
283307
/// No description provided for @loading.
284308
///
285309
/// In en, this message translates to:
@@ -382,6 +406,12 @@ abstract class ClerkSdkLocalizations {
382406
/// **'or'**
383407
String get or;
384408

409+
/// No description provided for @passkey.
410+
///
411+
/// In en, this message translates to:
412+
/// **'passkey'**
413+
String get passkey;
414+
385415
/// No description provided for @password.
386416
///
387417
/// In en, this message translates to:
@@ -394,6 +424,12 @@ abstract class ClerkSdkLocalizations {
394424
/// **'Password and password confirmation must match'**
395425
String get passwordAndPasswordConfirmationMustMatch;
396426

427+
/// No description provided for @passwordConfirmation.
428+
///
429+
/// In en, this message translates to:
430+
/// **'password confirmation'**
431+
String get passwordConfirmation;
432+
397433
/// No description provided for @passwordMatchError.
398434
///
399435
/// In en, this message translates to:
@@ -490,6 +526,12 @@ abstract class ClerkSdkLocalizations {
490526
/// **'Sign in by entering a code sent to you by text message'**
491527
String get signInByEnteringACodeSentToYouByTextMessage;
492528

529+
/// No description provided for @signInError.
530+
///
531+
/// In en, this message translates to:
532+
/// **'Unsupported sign in attempt: {arg}'**
533+
String signInError(String arg);
534+
493535
/// No description provided for @signInTo.
494536
///
495537
/// In en, this message translates to:
@@ -580,6 +622,12 @@ abstract class ClerkSdkLocalizations {
580622
/// **'Verify your phone number'**
581623
String get verifyYourPhoneNumber;
582624

625+
/// No description provided for @web3Wallet.
626+
///
627+
/// In en, this message translates to:
628+
/// **'web3 wallet'**
629+
String get web3Wallet;
630+
583631
/// No description provided for @welcomeBackPleaseSignInToContinue.
584632
///
585633
/// In en, this message translates to:

packages/clerk_flutter/lib/src/generated/clerk_sdk_localizations_en.dart

+26
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ class ClerkSdkLocalizationsEn extends ClerkSdkLocalizations {
5555
@override
5656
String get and => 'and';
5757

58+
@override
59+
String get authenticatorApp => 'authenticator app';
60+
61+
@override
62+
String get backupCode => 'backup code';
63+
5864
@override
5965
String get cancel => 'Cancel';
6066

@@ -103,6 +109,9 @@ class ClerkSdkLocalizationsEn extends ClerkSdkLocalizations {
103109
@override
104110
String get failed => 'FAILED';
105111

112+
@override
113+
String get firstName => 'first name';
114+
106115
@override
107116
String invalidEmailAddress(String address) {
108117
return 'Invalid email address: $address';
@@ -118,6 +127,9 @@ class ClerkSdkLocalizationsEn extends ClerkSdkLocalizations {
118127
return 'JWT poorly formatted: $arg';
119128
}
120129

130+
@override
131+
String get lastName => 'last name';
132+
121133
@override
122134
String get loading => 'Loading…';
123135

@@ -181,13 +193,19 @@ class ClerkSdkLocalizationsEn extends ClerkSdkLocalizations {
181193
@override
182194
String get or => 'or';
183195

196+
@override
197+
String get passkey => 'passkey';
198+
184199
@override
185200
String get password => 'Password';
186201

187202
@override
188203
String get passwordAndPasswordConfirmationMustMatch =>
189204
'Password and password confirmation must match';
190205

206+
@override
207+
String get passwordConfirmation => 'password confirmation';
208+
191209
@override
192210
String get passwordMatchError =>
193211
'Password and password confirmation must match';
@@ -242,6 +260,11 @@ class ClerkSdkLocalizationsEn extends ClerkSdkLocalizations {
242260
String get signInByEnteringACodeSentToYouByTextMessage =>
243261
'Sign in by entering a code sent to you by text message';
244262

263+
@override
264+
String signInError(String arg) {
265+
return 'Unsupported sign in attempt: $arg';
266+
}
267+
245268
@override
246269
String signInTo(String name) {
247270
return 'Sign in to $name';
@@ -293,6 +316,9 @@ class ClerkSdkLocalizationsEn extends ClerkSdkLocalizations {
293316
@override
294317
String get verifyYourPhoneNumber => 'Verify your phone number';
295318

319+
@override
320+
String get web3Wallet => 'web3 wallet';
321+
296322
@override
297323
String get welcomeBackPleaseSignInToContinue =>
298324
'Welcome back! Please sign in to continue';

packages/clerk_flutter/lib/src/utils/localization_extensions.dart

+11-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ extension ClerkAuthErrorExtension on clerk.AuthError {
2828
return localizations.noSuchFirstFactorStrategy(argument.toString());
2929
case clerk.AuthErrorCode.noSuchSecondFactorStrategy:
3030
return localizations.noSuchSecondFactorStrategy(argument.toString());
31+
case clerk.AuthErrorCode.signInError:
32+
return localizations.signInError(argument.toString());
3133
default:
3234
return toString();
3335
}
@@ -94,7 +96,15 @@ extension ClerkUserAttributeLocalization on clerk.UserAttribute {
9496
clerk.UserAttribute.emailAddress => localizations.emailAddress,
9597
clerk.UserAttribute.phoneNumber => localizations.phoneNumber,
9698
clerk.UserAttribute.username => localizations.username,
97-
_ => name,
99+
clerk.UserAttribute.firstName => localizations.firstName,
100+
clerk.UserAttribute.lastName => localizations.lastName,
101+
clerk.UserAttribute.password => localizations.password,
102+
clerk.UserAttribute.passwordConfirmation =>
103+
localizations.passwordConfirmation,
104+
clerk.UserAttribute.web3Wallet => localizations.web3Wallet,
105+
clerk.UserAttribute.authenticatorApp => localizations.authenticatorApp,
106+
clerk.UserAttribute.backupCode => localizations.backupCode,
107+
clerk.UserAttribute.passkey => localizations.passkey,
98108
};
99109
}
100110
}

0 commit comments

Comments
 (0)