Skip to content

Commit 0ac7c13

Browse files
committed
feat(package): support custom text (i18n) for the main component #226 #76
1 parent c2a23aa commit 0ac7c13

File tree

2 files changed

+61
-66
lines changed

2 files changed

+61
-66
lines changed

src/module/components/ngx-auth-firebaseui/auth.component.html

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
</mat-tab>
5151

5252
<!--Sign in tab-->
53-
<mat-tab label="Sign in">
53+
<mat-tab [label]="signInTabText">
5454
<mat-card>
55-
<mat-card-title>Signing in</mat-card-title>
55+
<mat-card-title>{{signInCardTitleText}}</mat-card-title>
5656
<mat-card-content>
5757
<form [formGroup]="signInFormGroup"
5858
(ngSubmit)="signInFormGroup.valid &&
@@ -61,25 +61,25 @@
6161
{email:signInFormGroup.value.email, password: signInFormGroup.value.password})">
6262
<div fxLayout="column" fxLayoutAlign="center">
6363
<mat-form-field [appearance]="appearance">
64-
<mat-label>E-mail</mat-label>
64+
<mat-label>{{emailText}}</mat-label>
6565
<input matInput
66-
placeholder="E-mail"
66+
[placeholder]="emailText"
6767
formControlName="email"
6868
required>
6969
<mat-icon matSuffix [color]="color">email</mat-icon>
7070
<mat-error *ngIf="signInEmailFormControl.hasError('required')">
71-
E-mail is required
71+
{{emailErrorRequiredText}}
7272
</mat-error>
7373
<mat-error *ngIf="signInEmailFormControl.hasError('pattern')">
74-
Please enter a valid e-mail address
74+
{{emailErrorPatternText}}
7575
</mat-error>
7676
</mat-form-field>
7777

7878
<mat-form-field [appearance]="appearance">
79-
<mat-label>Password</mat-label>
79+
<mat-label>{{passwordText}}</mat-label>
8080
<input matInput
8181
type="password"
82-
placeholder="Password"
82+
[placeholder]="passwordText"
8383
minlength="6"
8484
maxlength="25"
8585
formControlName="password"
@@ -89,7 +89,7 @@
8989
{{signInFormGroup.value.password.length}} / 25
9090
</mat-hint>
9191
<mat-error *ngIf="sigInPasswordFormControl.hasError('required')">
92-
Please do not forget the password
92+
{{passwordErrorRequiredText}}
9393
</mat-error>
9494
<mat-error *ngIf="sigInPasswordFormControl.hasError('minlength')">
9595
The password must be at least 6 characters long.
@@ -104,7 +104,7 @@
104104
type="submit"
105105
class="space-top"
106106
[color]="color">
107-
Log In
107+
{{loginButtonText}}
108108
</button>
109109

110110
</div>
@@ -116,7 +116,7 @@
116116
class="space-top"
117117
[color]="color"
118118
(click)="createForgotPasswordTab()">
119-
Forgot Password?
119+
{{forgotPasswordButtonText}}
120120
</button>
121121
</div>
122122

@@ -128,9 +128,9 @@
128128
</mat-tab>
129129

130130
<!--tab register-->
131-
<mat-tab label="Register" *ngIf="registrationEnabled">
131+
<mat-tab [label]="registerTabText" *ngIf="registrationEnabled">
132132
<mat-card>
133-
<mat-card-title>Registration</mat-card-title>
133+
<mat-card-title>{{registerCardTitleText}}</mat-card-title>
134134
<div *ngIf="!authProcess.emailConfirmationSent;then register else confirm"></div>
135135
<ng-template #register>
136136
<mat-card-content fxLayout="column" fxLayoutAlign="center">
@@ -140,9 +140,9 @@
140140
<!--name-->
141141
<mat-form-field [appearance]="appearance">
142142
<!--labels will work only with @angular/material@6.2.0 -->
143-
<mat-label>Name</mat-label>
143+
<mat-label>{{nameText}}</mat-label>
144144
<input matInput
145-
placeholder="Name"
145+
[placeholder]="Name"
146146
minlength="2"
147147
maxlength="30"
148148
[formControl]="sigUpNameFormControl"
@@ -152,40 +152,39 @@
152152
{{signUpFormGroup.value.name?.length}} / 25
153153
</mat-hint>
154154
<mat-error *ngIf="sigUpNameFormControl.hasError('required')">
155-
Name is required
155+
{{nameErrorRequiredText}}
156156
</mat-error>
157157
<mat-error *ngIf="sigUpNameFormControl.hasError('minlength')">
158-
The name is too short!
158+
{{nameErrorMinLengthText}}
159159
</mat-error>
160160
<mat-error *ngIf="sigUpNameFormControl.hasError('maxlength')">
161-
The name is too long!
161+
{{nameErrorMaxLengthText}}
162162
</mat-error>
163163
</mat-form-field>
164164

165165
<!--email-->
166166
<mat-form-field [appearance]="appearance">
167-
<mat-label>E-mail</mat-label>
167+
<mat-label>{{emailText}}</mat-label>
168168
<input matInput
169-
placeholder="E-mail"
169+
[placeholder]="emailText"
170170
type="email"
171171
[formControl]="sigUpEmailFormControl">
172172
<mat-icon matSuffix [color]="color">email</mat-icon>
173173
<mat-error *ngIf="sigUpEmailFormControl.hasError('required')">
174-
E-mail is required
174+
{{emailErrorRequiredText}}
175175
</mat-error>
176176
<mat-error *ngIf="sigUpEmailFormControl.hasError('pattern')">
177-
Please enter a valid e-mail address
177+
{{emailErrorPatternText}}
178178
</mat-error>
179179
</mat-form-field>
180180

181181
<!--password-->
182182
<div fxLayout="column">
183-
184183
<mat-form-field [appearance]="appearance">
185-
<mat-label>Password</mat-label>
184+
<mat-label>{{passwordText}}</mat-label>
186185
<input matInput
187186
[type]="toggle.type"
188-
placeholder="password"
187+
[placeholder]="passwordText"
189188
name="password"
190189
[formControl]="sigUpPasswordFormControl"
191190
required>
@@ -198,7 +197,7 @@
198197
</mat-hint>
199198

200199
<mat-error *ngIf="sigUpPasswordFormControl.hasError('required')" class="cut-text">
201-
Please do not forget the password
200+
{{passwordErrorRequiredText}}
202201
</mat-error>
203202

204203
<mat-error *ngIf="sigUpPasswordFormControl.hasError('minlength')" class="cut-text">
@@ -221,7 +220,7 @@
221220
style="margin-top: 20px"
222221
type="submit"
223222
[color]="color">
224-
Register
223+
{{registerButtonText}}
225224
</button>
226225

227226
</div>
@@ -233,7 +232,7 @@
233232
[color]="color"
234233
(click)="processLegalSignUP(authProvider.ANONYMOUS)">
235234
<mat-icon>fingerprint</mat-icon>
236-
continue as guest
235+
{{guestButtonText}}
237236
</button>
238237

239238
</mat-card-content>

src/module/components/ngx-auth-firebaseui/auth.component.ts

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,17 @@ export const PHONE_NUMBER_REGEX = new RegExp(/^\+(?:[0-9] ?){6,14}[0-9]$/);
2727

2828
export class AuthComponent implements OnInit, OnChanges, OnDestroy {
2929

30-
@Input()
31-
providers: string[] | string = AuthProvider.ALL; // google, facebook, twitter, github as array or all as one single string
32-
33-
@Input()
34-
appearance: MatFormFieldAppearance;
35-
36-
@Input()
37-
tabIndex: number | null;
38-
39-
@Input()
40-
registrationEnabled = true;
41-
42-
@Input()
43-
resetPasswordEnabled = true;
44-
45-
@Input()
46-
guestEnabled = true;
47-
48-
@Input()
49-
tosUrl: string;
50-
51-
@Input()
52-
privacyPolicyUrl: string;
53-
54-
@Input()
55-
goBackURL: string;
56-
57-
@Input()
58-
messageOnAuthSuccess: string;
59-
60-
@Input()
61-
messageOnAuthError: string;
30+
@Input() providers: string[] | string = AuthProvider.ALL; // google, facebook, twitter, github as array or all as one single string
31+
@Input() appearance: MatFormFieldAppearance;
32+
@Input() tabIndex: number | null;
33+
@Input() registrationEnabled = true;
34+
@Input() resetPasswordEnabled = true;
35+
@Input() guestEnabled = true;
36+
@Input() tosUrl: string;
37+
@Input() privacyPolicyUrl: string;
38+
@Input() goBackURL: string;
39+
@Input() messageOnAuthSuccess: string;
40+
@Input() messageOnAuthError: string;
6241

6342
// Customize the text
6443
// Reset Password Tab
@@ -70,16 +49,33 @@ export class AuthComponent implements OnInit, OnChanges, OnDestroy {
7049
@Input() resetPasswordInstructionsText = 'Reset requested. Check your e-mail instructions.';
7150

7251
// SignIn Tab
73-
@Input()
74-
signInTabText = '';
52+
@Input() signInTabText = 'Sign in';
53+
@Input() signInCardTitleText = 'Signing in';
54+
@Input() loginButtonText = 'Log In';
55+
@Input() forgotPasswordButtonText = 'Forgot Password?';
56+
57+
// Common
58+
@Input() nameText = 'Name';
59+
@Input() nameErrorRequiredText = 'Name is required';
60+
@Input() nameErrorMinLengthText = 'The name is too short!';
61+
@Input() nameErrorMaxLengthText = 'The name is too long!';
62+
63+
@Input() emailText = 'E-mail';
64+
@Input() emailErrorRequiredText = 'E-mail is required';
65+
@Input() emailErrorPatternText = 'Please enter a valid e-mail address';
66+
67+
@Input() passwordText = 'Password';
68+
@Input() passwordErrorRequiredText = 'Password is required';
7569

7670
// Register Tab
71+
@Input() registerTabText = 'Regsiter';
72+
@Input() registerCardTitleText = 'Registration';
73+
@Input() registerButtonText = 'Register';
74+
@Input() guestButtonText = 'continue as guest';
7775

78-
@Output()
79-
onSuccess: any;
76+
@Output() onSuccess: any;
8077

81-
@Output()
82-
onError: any;
78+
@Output() onError: any;
8379

8480
authProvider = AuthProvider;
8581
passwordResetWished: boolean;

0 commit comments

Comments
 (0)