ngx-translate / core

The internationalization (i18n) library for Angular
MIT License
4.53k stars 579 forks source link

HMR does not reload when translation file is changed #882

Open denniske opened 6 years ago

denniske commented 6 years ago

Current behavior

When hmr is enabled and a translation file is changed the application is not reloaded.

Expected behavior

When a translation file is changed the application hot reloads and displays new translations.

How do you think that we should fix this?

Can this even be fixed? Do I need to use the WebpackTranslateLoader instead of TranslateHttpLoader to fix this? Is there any other way?

Minimal reproduction of the problem with instructions

Go to https://stackblitz.com/github/ngx-translate/example Change something in en.json App is not reloaded

Environment


ngx-translate version: 10.0.1
Angular version: 6.0.0

Browser:
- [x ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

XuZhaoTong commented 3 years ago
 class WebpackTranslateLoader implements TranslateLoader {
  getTranslation(lang: string): Observable<any> {
    return from(import(`../assets/i18n/${lang}.json`));
  }
}
...
TranslateModule.forRoot({
  loader: {
    provide: TranslateLoader,
    useClass: WebpackTranslateLoader,
  },
}),