So, I have a string value that I need to pass to another function. For instance, if the string is 'eng', I want it to be converted to 'en'. I'm looking for a solution that does not involve using slice or if statements. I attempted to create an enum, but unfortunately, that did not work as expected.
ngOnInit(): void {
this.setLocaleDateFormat(this.translateService.currentLang);
}
setLocaleDateFormat(language: Languages): void {
this.dateAdapter.setLocale(language); }
export enum Languages {
'eng' = 'en',
'slk' = 'sk',
'cze' = 'cz',
}
Essentially, I need to pass a value and based on some criteria, change it to something else. For example, I receive 'eng' but I want to set the locale to 'en'.