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

View File

@ -142,14 +142,20 @@ export class NttGanttComponent implements OnInit {
this.deMap.set('field1', 'Kurzbeschreibung'); this.deMap.set('field1', 'Kurzbeschreibung');
this.enMap.set('field1', 'Summary'); this.enMap.set('field1', 'Summary');
this.deMap.set('dateRangeLabel', 'Datumsbereich auswählen'); 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.initLanguge(); this.language = 'DE';
}else{
this.language = 'EN';
} }
initLanguge(){ this.initLanguge(true);
}
initLanguge(initial: boolean = false){
if(this.language == 'DE'){ if(this.language == 'DE'){
this.dataService.selectedLanguage = 'DE';
this.lMap = this.deMap; this.lMap = this.deMap;
this.scalars = ['Woche-Tag', 'Monat-Woche', 'Jahr-Monat']; this.scalars = ['Woche-Tag', 'Monat-Woche', 'Jahr-Monat'];
this.selectedScalar = 'Monat-Woche'; this.selectedScalar = 'Monat-Woche';
@ -162,6 +168,7 @@ export class NttGanttComponent implements OnInit {
] ]
} }
else{ else{
this.dataService.selectedLanguage = 'EN';
this.lMap = this.enMap; this.lMap = this.enMap;
this.scalars = ['Week-Day', 'Month-Week', 'Year-Month']; this.scalars = ['Week-Day', 'Month-Week', 'Year-Month'];
this.selectedScalar = 'Month-Week'; this.selectedScalar = 'Month-Week';
@ -173,8 +180,14 @@ export class NttGanttComponent implements OnInit {
{ field: 'StartDate', headerText: 'Planned Start-Date', format : {type:'date', format:'dd.MM.yyyy'}} { field: 'StartDate', headerText: 'Planned Start-Date', format : {type:'date', format:'dd.MM.yyyy'}}
] ]
} }
if(!initial){
this.refreshData();
} }
}