When the module TranslateModule cohabites with Module HttpClientInMemoryWebApiModule, the ngx translate service can't find resources of path ./assets/i18n/.json
I had to comment the module HttpClientInMemoryWebApiModule to make the translation service functions, like in the code below:
// Import of angular modules
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule, HttpClient } from '@angular/common/http';
// Import of translation feature
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
// Import of data mocking
import { InMemoryDataService } from './serverSimulator/in-memory-data.service';
// Import of app self modules
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
export function HttpLoaderFactory(http:HttpClient) {
return new TranslateHttpLoader(http);
}
@NgModule({
declarations: [
AppComponent,
ServiceDeliveryPointsComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
})
// this import is not compatible with translateModule use and cause a file not found exception.
//HttpClientInMemoryWebApiModule.forRoot(
// InMemoryDataService, { dataEncapsulation: false}
//)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Expected behavior
That these two modules don't get interference when both of them are used.
How do you think that we should fix this?
Minimal reproduction of the problem with instructions
Environment
ngx-translate version: 7.0.2
Angular version: 7.0.0
Browser:
- [ ] Chrome (desktop) version 71.0.3578.98
- [ ] 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
For Tooling issues:
- Node version: v10.14.2
- Platform: Mac
Others:
Current behavior
When the module TranslateModule cohabites with Module HttpClientInMemoryWebApiModule, the ngx translate service can't find resources of path ./assets/i18n/.json
I had to comment the module HttpClientInMemoryWebApiModule to make the translation service functions, like in the code below:
// Import of angular modules import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { HttpClientModule, HttpClient } from '@angular/common/http'; // Import of translation feature import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; // Import of data mocking import { InMemoryDataService } from './serverSimulator/in-memory-data.service'; // Import of app self modules import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; export function HttpLoaderFactory(http:HttpClient) { return new TranslateHttpLoader(http); } @NgModule({ declarations: [ AppComponent, ServiceDeliveryPointsComponent ], imports: [ BrowserModule, AppRoutingModule, HttpClientModule, TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: HttpLoaderFactory, deps: [HttpClient] } }) // this import is not compatible with translateModule use and cause a file not found exception. //HttpClientInMemoryWebApiModule.forRoot( // InMemoryDataService, { dataEncapsulation: false} //) ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
Expected behavior
That these two modules don't get interference when both of them are used.
How do you think that we should fix this?
Minimal reproduction of the problem with instructions
Environment