Auto Detect Browser Language/Done

main
manueltauber 2023-05-25 12:36:58 +02:00
parent ecbf827820
commit 6d41d37c6e
2 changed files with 31 additions and 7 deletions

View File

@ -19,6 +19,7 @@ export class DataService {
private contracts: any [];
private paketTypes: any [];
private totalSize: number = null;
public selectedLanguage: string = 'DE';
/**
* This constructor builds the dataService and fetches the states from the backend
* @param http
@ -296,11 +297,21 @@ export class DataService {
}
getStateNameById(stateNr): String {
for (let state of this.states) {
if(stateNr == state.actualState){
return state.stateNameDE;
}
if(this.selectedLanguage == 'EN'){
for (let state of this.states) {
if(stateNr == state.actualState){
return state.stateNameEN;
}
}
}
if(this.selectedLanguage == 'DE'){
for (let state of this.states) {
if(stateNr == state.actualState){
return state.stateNameDE;
}
}
}
return "";
}

View File

@ -142,14 +142,20 @@ export class NttGanttComponent implements OnInit {
this.deMap.set('field1', 'Kurzbeschreibung');
this.enMap.set('field1', 'Summary');
this.deMap.set('dateRangeLabel', 'Datumsbereich auswählen');
this.enMap.set('dateRangeLabel', 'Select Date Range')
this.enMap.set('dateRangeLabel', 'Select Date Range');
if(navigator.language=='de-DE'){
this.language = 'DE';
}else{
this.language = 'EN';
}
this.initLanguge();
this.initLanguge(true);
}
initLanguge(){
initLanguge(initial: boolean = false){
if(this.language == 'DE'){
this.dataService.selectedLanguage = 'DE';
this.lMap = this.deMap;
this.scalars = ['Woche-Tag', 'Monat-Woche', 'Jahr-Monat'];
this.selectedScalar = 'Monat-Woche';
@ -162,6 +168,7 @@ export class NttGanttComponent implements OnInit {
]
}
else{
this.dataService.selectedLanguage = 'EN';
this.lMap = this.enMap;
this.scalars = ['Week-Day', 'Month-Week', 'Year-Month'];
this.selectedScalar = 'Month-Week';
@ -173,6 +180,10 @@ export class NttGanttComponent implements OnInit {
{ field: 'StartDate', headerText: 'Planned Start-Date', format : {type:'date', format:'dd.MM.yyyy'}}
]
}
if(!initial){
this.refreshData();
}
}
@ -180,6 +191,8 @@ export class NttGanttComponent implements OnInit {
/**
* The function ngOnInit sets values which are required for rendering the gantt Chart. Furthermore it trims the resources (Changes Array) and sets the paginator to the first page.
*/