Reputation: 984
I used i18n for translation my app, but when I loaded my app I got error :
GET http://localhost:4200/i18n/fr.json 404 (Not Found)
I added json file (fr, de) in folder assets/i18n/fr.json and assets/i18n/de.json.
My code in component.ts
constructor(private translate: TranslateService) {
translate.addLangs(["de", "fr"]);
translate.setDefaultLang('fr');
let browserLang = translate.getBrowserLang();
console.log(browserLang);
translate.use(browserLang.match(/fr|de/) ? browserLang : 'fr');
}
Where can I add the json file for resolve it ?
Upvotes: 0
Views: 279
Reputation: 21
You can import your .json
files on top of your i18n.service
file like so:
import de from 'assets/i18n/de.json';
import fr from 'assets/i18n/fr.json';
Upvotes: 1