I am using ngx-translate for a multi-language app.
app.module.ts
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient, './assets/i18n');
}
@NgModule({
[
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
...
]
export class AppModule {
constructor(translate: TranslateService) {
translate.setDefaultLang('en');
translate.use( 'en');
}
Followed Angular Universal: server-side rendering instructions, and run app in SSR mode:
- the page is loaded with the lang strings ('Home.Title')
- there is an HTTP call for en.json
- the strings are replaced with the translation ('My site')
What do I need to change in order that the translations will be rendered in server?