Closed mtabaj closed 2 years ago
I am not sure what is the issue. If somebody has an idea please create PR. @mtabaj If you need a workaround just copy the code from https://github.com/denniske/ngx-translate-multi-http-loader/blob/master/src/multi-http-loader.ts into your project instead using the library using npm to solve this issue.
Hello @mtabaj, please make sure you are using v8.0.2
version of the library, also please double check if you have imported HttpClient
from @angular/common/http
so the code in your root module should be similar to this:
import { HttpClient, HttpClientModule } from '@angular/common/http';
/////// other imports
export function HttpLoaderFactory(http: HttpClient) {
return new MultiTranslateHttpLoader(http, [
{ prefix: TRANSLATION_PREFIX, suffix: '/common.json' },
{ prefix: TRANSLATION_PREFIX, suffix: '/shared.json' },
{ prefix: TRANSLATION_PREFIX, suffix: '/auth.json' },
{ prefix: TRANSLATION_PREFIX, suffix: '/error.json' },
]);
}
@NgModule({
declarations: [],
imports: [
CommonModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient], //. <------- this is important
},
defaultLanguage: DEFAULT_LANGUAGE,
}),
]
})
export class AppModule { }
I don't know what's the problem here. But with the 8.0.2 version, I have to remove the HttpClient
type from the HttpLoaderFactory
.
export function HttpLoaderFactory(http) { ... }
is ok.
@mtabaj Close as fixed in the latest release https://github.com/rbalet/ngx-translate-multi-http-loader/releases/tag/v9.0.0.
Please open the issue again in case this wouldn't be the case
Thanks @rbalet for all the good work! 🚀 I did the upgrade and it worked smoothly 🥇
Thanks @rbalet !
When I use as your documentation
`export function HttpLoaderFactory(http: HttpClient) { return new MultiTranslateHttpLoader(http, [ {prefix: "./assets/translate/core/", suffix: ".json"}, {prefix: "./assets/translate/shared/", suffix: ".json"}, ]); }
There is an error`
TS2345: Argument of type 'import("F:/baps/baps_14/node_modules/@angular/common/http/http").HttpClient' is not assignable to parameter of type 'import("F:/baps/baps_14/node_modules/ngx-translate-multi-http-loader/node_modules/@angular/common/http/index").HttpClient'. Types have separate declarations of a private property 'handler'.
Help please