Hello so I'm getting a string value and I want to pass it to another function. So for example if I get 'eng' I want it to be 'en'. I don't want to use slice or if. I tried making an enum but that didn't work.
ngOnInit(): void {
this.setLocaleDateFormat(this.translateService.currentLang);
}
setLocaleDateFormat(language: Languages): void {
this.dateAdapter.setLocale(language); }
export enum Languages {
'eng' = 'en',
'slk' = 'sk',
'cze' = 'cz',
}
So I want to pass the value and based on some template change it to something else. I'm getting eng but I want to setLocale to en for expample.
From you post, I believe this.translateService.currentLang
will return 'eng'. I doubt this but going back to your question. Languages should not be an enum. It should be a constant object.
export const Languages = {
eng: 'en',
slk: 'sk',
cze: 'cz',
};
setLocaleDateFormat(): void {
this.dateAdapter.setLocale(Languages[this.translateService.currentLang]);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments