'Angular, dynamic JSON import declaration in Typescript
I use the javascript command 'navigator.language' in app.components.ts to determine the language of the browser.
The corresponding JSON file should then be loaded.
In pure javascript I could do the following:
var userLang = navigator.language;
if (userLang == "en") {
var lanFile = "/locale/" + userLang + ".json";
}
How can I do this in Angular?
The following code does not work, but shows what I would like to have:
var userLang = navigator.language;
import text_en from './json/' + userLang + '.json';
Anybody out there who have a workaround for me?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
