change datepicker dialog language

main
Said Gedik 2024-07-31 14:17:47 +02:00
parent 8f2a33fcef
commit a478738fa9
1 changed files with 15 additions and 3 deletions

View File

@ -22,6 +22,8 @@ import { SavePresetUnderDialogComponent } from '../save-preset-under-dialog/save
import { Location } from '@angular/common';
import { environment } from 'src/environments/environment';
import { GanttModule, ResizeService } from '@syncfusion/ej2-angular-gantt';
import { DateAdapter } from '@angular/material/core';
import { MAT_DATE_LOCALE } from '@angular/material/core';
export const MY_DATE_FORMATS = {
@ -197,7 +199,7 @@ export class NttGanttComponent implements OnInit {
* @param dataService injects the dataService for data management and backend communication
* @param matDialog injects the matDialog
*/
constructor(public languageService: LanguageService, public dataService: DataService, public matDialog: MatDialog, private _snackBar: MatSnackBar, public errorService: ErrorService, private location: Location) {
constructor(public languageService: LanguageService, public dataService: DataService, public matDialog: MatDialog, private _snackBar: MatSnackBar, public errorService: ErrorService, private location: Location, private dateAdapter: DateAdapter<Date>) {
this.initLanguge(true);
}
@ -684,9 +686,18 @@ export class NttGanttComponent implements OnInit {
*/
public languageChange(args: any) {
this.languageService.languageChange(args.value),
this.initLanguge();
this.initLanguge();
this.plantimeComponent.changeLanguage();
this.editUserPreferences();
this.updateDatePickerLocale();
}
private updateDatePickerLocale() {
if (this.languageService.language === 'DE') {
this.dateAdapter.setLocale('de');
} else {
this.dateAdapter.setLocale('en');
}
}
/**
@ -699,11 +710,12 @@ export class NttGanttComponent implements OnInit {
if (this.languageService.language == 'DE') {
this.scalars = ['Monat', 'Jahr'];
this.selectedScalar = 'Monat';
this.dateAdapter.setLocale('de');
}
else {
this.scalars = ['Month', 'Year'];
this.selectedScalar = 'Month';
this.dateAdapter.setLocale('en');
}
this.columns = this.languageService.getColumns();
if (!initial) {