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
This commit is contained in:
Sascha Szott
2025-02-06 22:05:36 +01:00
committed by GitHub
parent 8184acc480
commit be6de64fcd
5 changed files with 26 additions and 8 deletions

View File

@@ -14,7 +14,7 @@
[(ngModel)]="initialYear"
[value]="year"
[invalid]="showErrorMessages"
[placeholder]='yearPlaceholder'
[placeholder]="'form.date-picker.placeholder.year' | translate"
(blur)="onBlur($event)"
(change)="onChange($event)"
(focus)="onFocus($event)"
@@ -29,7 +29,7 @@
[size]="6"
[(ngModel)]="initialMonth"
[value]="month"
[placeholder]="monthPlaceholder"
[placeholder]="'form.date-picker.placeholder.month' | translate"
[disabled]="!year || model.disabled"
(blur)="onBlur($event)"
(change)="onChange($event)"
@@ -45,7 +45,7 @@
[size]="2"
[(ngModel)]="initialDay"
[value]="day"
[placeholder]="dayPlaceholder"
[placeholder]="'form.date-picker.placeholder.day' | translate"
[disabled]="!month || model.disabled"
(blur)="onBlur($event)"
(change)="onChange($event)"

View File

@@ -24,7 +24,10 @@ import {
DynamicFormLayoutService,
DynamicFormValidationService,
} from '@ng-dynamic-forms/core';
import { TranslateService } from '@ngx-translate/core';
import {
TranslateModule,
TranslateService,
} from '@ngx-translate/core';
import { of as observableOf } from 'rxjs';
import {
@@ -80,6 +83,7 @@ describe('DsDatePickerComponent test suite', () => {
NgbModule,
DsDatePickerComponent,
TestComponent,
TranslateModule.forRoot(),
],
providers: [
ChangeDetectorRef,

View File

@@ -22,6 +22,7 @@ import {
DynamicFormLayoutService,
DynamicFormValidationService,
} from '@ng-dynamic-forms/core';
import { TranslateModule } from '@ngx-translate/core';
import isEqual from 'lodash/isEqual';
import { BtnDisabledDirective } from '../../../../../btn-disabled.directive';
@@ -42,6 +43,7 @@ export const DS_DATE_PICKER_SEPARATOR = '-';
NgIf,
NumberPickerComponent,
FormsModule,
TranslateModule,
BtnDisabledDirective,
],
standalone: true,
@@ -74,10 +76,6 @@ export class DsDatePickerComponent extends DynamicFormControlComponent implement
minDay = 1;
maxDay = 31;
yearPlaceholder = 'year';
monthPlaceholder = 'month';
dayPlaceholder = 'day';
disabledMonth = true;
disabledDay = true;

View File

@@ -5998,4 +5998,14 @@
// "workspace-item.delete.notification.error.content": "The workspace item could not be deleted",
"workspace-item.delete.notification.error.content": "Das Workspace-Item konnte nicht gelöscht werden.",
// "form.date-picker.placeholder.year": "Year",
"form.date-picker.placeholder.year": "Jahr",
// "form.date-picker.placeholder.month": "Month",
"form.date-picker.placeholder.month": "Monat",
// "form.date-picker.placeholder.day": "Day",
"form.date-picker.placeholder.day": "Tag",
}

View File

@@ -6758,6 +6758,12 @@
"search.filters.filter.notifyEndorsement.label": "Search Notify Endorsement",
"form.date-picker.placeholder.year": "Year",
"form.date-picker.placeholder.month": "Month",
"form.date-picker.placeholder.day": "Day",
"item.page.cc.license.title": "Creative Commons license",
"item.page.cc.license.disclaimer": "Except where otherwised noted, this item's license is described as",