Skip to content

Commit c6deb22

Browse files
saschaszotttdonohue
authored andcommitted
use translation service to determine placeholder values of date picker (#2827)
* use translation service to determine placeholder values * added translation of date-picker placeholder values * added German translations of date-picker placeholder values * fix lint warning: added missing comma * fix lint warning: removed trailing spaces * fixed broken tests * fixed lint warning * try to mock TranslateService correctly * remove TranslateService mock * removed imports * fixed lint warnings * fixed lint warnings * fixed lint warning * fixed lint warning * fixed lint error * fixed lint errors * removed TestComponent * added imports * removed declarations * fixed lint error * fix lint error (invalid sorting) * finally fixing lint error * use translation pipe directly in template * move translation of placeholders into HTML template * remove TranslateService dependency
1 parent 59e6c4a commit c6deb22

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
[(ngModel)]="initialYear"
1515
[value]="year"
1616
[invalid]="showErrorMessages"
17-
[placeholder]='yearPlaceholder'
17+
[placeholder]="'form.date-picker.placeholder.year' | translate"
1818
(blur)="onBlur($event)"
1919
(change)="onChange($event)"
2020
(focus)="onFocus($event)"
@@ -29,7 +29,7 @@
2929
[size]="6"
3030
[(ngModel)]="initialMonth"
3131
[value]="month"
32-
[placeholder]="monthPlaceholder"
32+
[placeholder]="'form.date-picker.placeholder.month' | translate"
3333
[disabled]="!year || model.disabled"
3434
(blur)="onBlur($event)"
3535
(change)="onChange($event)"
@@ -45,7 +45,7 @@
4545
[size]="2"
4646
[(ngModel)]="initialDay"
4747
[value]="day"
48-
[placeholder]="dayPlaceholder"
48+
[placeholder]="'form.date-picker.placeholder.day' | translate"
4949
[disabled]="!month || model.disabled"
5050
(blur)="onBlur($event)"
5151
(change)="onChange($event)"

src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import {
2424
DynamicFormLayoutService,
2525
DynamicFormValidationService,
2626
} from '@ng-dynamic-forms/core';
27-
import { TranslateService } from '@ngx-translate/core';
27+
import {
28+
TranslateModule,
29+
TranslateService,
30+
} from '@ngx-translate/core';
2831
import { of as observableOf } from 'rxjs';
2932

3033
import {
@@ -80,6 +83,7 @@ describe('DsDatePickerComponent test suite', () => {
8083
NgbModule,
8184
DsDatePickerComponent,
8285
TestComponent,
86+
TranslateModule.forRoot(),
8387
],
8488
providers: [
8589
ChangeDetectorRef,

src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
DynamicFormLayoutService,
2323
DynamicFormValidationService,
2424
} from '@ng-dynamic-forms/core';
25+
import { TranslateModule } from '@ngx-translate/core';
2526
import isEqual from 'lodash/isEqual';
2627

2728
import { BtnDisabledDirective } from '../../../../../btn-disabled.directive';
@@ -42,6 +43,7 @@ export const DS_DATE_PICKER_SEPARATOR = '-';
4243
NgIf,
4344
NumberPickerComponent,
4445
FormsModule,
46+
TranslateModule,
4547
BtnDisabledDirective,
4648
],
4749
standalone: true,
@@ -74,10 +76,6 @@ export class DsDatePickerComponent extends DynamicFormControlComponent implement
7476
minDay = 1;
7577
maxDay = 31;
7678

77-
yearPlaceholder = 'year';
78-
monthPlaceholder = 'month';
79-
dayPlaceholder = 'day';
80-
8179
disabledMonth = true;
8280
disabledDay = true;
8381

src/assets/i18n/de.json5

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5992,4 +5992,14 @@
59925992

59935993
// "workspace-item.delete.notification.error.content": "The workspace item could not be deleted",
59945994
"workspace-item.delete.notification.error.content": "Das Workspace-Item konnte nicht gelöscht werden.",
5995+
5996+
5997+
// "form.date-picker.placeholder.year": "Year",
5998+
"form.date-picker.placeholder.year": "Jahr",
5999+
6000+
// "form.date-picker.placeholder.month": "Month",
6001+
"form.date-picker.placeholder.month": "Monat",
6002+
6003+
// "form.date-picker.placeholder.day": "Day",
6004+
"form.date-picker.placeholder.day": "Tag",
59956005
}

src/assets/i18n/en.json5

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6764,6 +6764,12 @@
67646764

67656765
"search.filters.filter.notifyEndorsement.label": "Search Notify Endorsement",
67666766

6767+
"form.date-picker.placeholder.year": "Year",
6768+
6769+
"form.date-picker.placeholder.month": "Month",
6770+
6771+
"form.date-picker.placeholder.day": "Day",
6772+
67676773
"item.page.cc.license.title": "Creative Commons license",
67686774

67696775
"item.page.cc.license.disclaimer": "Except where otherwised noted, this item's license is described as",

0 commit comments

Comments
 (0)