I want to place my application in http://example.com/my_dir path, first of all I had to add to my build command an option build --prod --base-href=/my_dir/
. All works fine but I have a problem only with translator files. Normaly I kept them in assets/i18n/ directory, how to change request path for this file to /my_dir/assetes/i18n ?
I use Angular 8 and TranslateModule
This is my config in app.module.ts
import {TranslateModule, TranslateLoader} from "@ngx-translate/core";
import {TranslateHttpLoader} from "@ngx-translate/http-loader";
// AoT requires an exported function for factories
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient);
}
imports: [
...,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
})
]
RESOLVED I added here to TranslateHttpLoader(httpClient)
// AoT requires an exported function for factories
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient);
}
additional prefix option
return new TranslateHttpLoader(httpClient, '/my_dir/assets/i18n/');
and it works fine