Skip to content

Commit 7fab963

Browse files
authored
Merge pull request DSpace#3965 from tdonohue/port_2827_to_7x
[Port dspace-7_x] use translation service to determine placeholder values of date picker
2 parents 9506412 + 7584b9e commit 7fab963

5 files changed

Lines changed: 24 additions & 8 deletions

File tree

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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
mockDynamicFormValidationService
1515
} from '../../../../../testing/dynamic-form-mock-services';
1616
import { By } from '@angular/platform-browser';
17+
import { TranslateModule } from '@ngx-translate/core';
1718

1819

1920
export const DATE_TEST_GROUP = new UntypedFormGroup({
@@ -51,7 +52,8 @@ describe('DsDatePickerComponent test suite', () => {
5152

5253
TestBed.configureTestingModule({
5354
imports: [
54-
NgbModule
55+
NgbModule,
56+
TranslateModule.forRoot(),
5557
],
5658
declarations: [
5759
DsDatePickerComponent,

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
@@ -9,6 +9,7 @@ import {
99
} from '@ng-dynamic-forms/core';
1010
import { DOCUMENT } from '@angular/common';
1111
import isEqual from 'lodash/isEqual';
12+
import { TranslateService } from '@ngx-translate/core';
1213

1314

1415
export type DatePickerFieldType = '_year' | '_month' | '_day';
@@ -48,17 +49,14 @@ export class DsDatePickerComponent extends DynamicFormControlComponent implement
4849
minDay = 1;
4950
maxDay = 31;
5051

51-
yearPlaceholder = 'year';
52-
monthPlaceholder = 'month';
53-
dayPlaceholder = 'day';
54-
5552
disabledMonth = true;
5653
disabledDay = true;
5754

5855
private readonly fields: DatePickerFieldType[] = ['_year', '_month', '_day'];
5956

6057
constructor(protected layoutService: DynamicFormLayoutService,
6158
protected validationService: DynamicFormValidationService,
59+
protected translateService: TranslateService,
6260
private renderer: Renderer2,
6361
@Inject(DOCUMENT) private _document: Document
6462
) {

src/assets/i18n/de.json5

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

55545554
// "workspace-item.delete.notification.error.content": "The workspace item could not be deleted",
55555555
"workspace-item.delete.notification.error.content": "Das Workspace-Item konnte nicht gelöscht werden.",
5556+
5557+
5558+
// "form.date-picker.placeholder.year": "Year",
5559+
"form.date-picker.placeholder.year": "Jahr",
5560+
5561+
// "form.date-picker.placeholder.month": "Month",
5562+
"form.date-picker.placeholder.month": "Monat",
5563+
5564+
// "form.date-picker.placeholder.day": "Day",
5565+
"form.date-picker.placeholder.day": "Tag",
55565566
}

src/assets/i18n/en.json5

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

18091809
"form.number-picker.increment": "Increment {{field}}",
18101810

1811+
"form.date-picker.placeholder.year": "Year",
1812+
1813+
"form.date-picker.placeholder.month": "Month",
1814+
1815+
"form.date-picker.placeholder.day": "Day",
1816+
18111817
"grant-deny-request-copy.deny": "Don't send copy",
18121818

18131819
"grant-deny-request-copy.email.back": "Back",

0 commit comments

Comments
 (0)