localize-router package breaks translation pipe

Viewed 191

I have successfully applied localized translations to my Angular project using ngx/translate package. Now I'm trying to apply localization routes (like /en/about) using localize-router package. I have followed the sample configuration on their page but as soon as I do that the translate pipe stop working:

src/app/section/section.component.html:1:19 - error NG8004: No pipe found with name 'translate'.

1 <p>{{ 'section' | translate }}</p>

This is my app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient, HttpClientModule } from '@angular/common/http';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AboutComponent } from './about/about.component';
import { SectionComponent } from './section/section.component';

import { LocalizeRouterModule, LocalizeRouterSettings, LocalizeParser } from 'localize-router';
import {LocalizeRouterHttpLoader} from 'localize-router-http-loader';

import { routes } from './app-routing.module';

@NgModule({
  declarations: [
    AppComponent,
    AboutComponent,
    SectionComponent
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    AppRoutingModule,
    TranslateModule.forRoot({
      defaultLanguage: 'en',
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [ HttpClient ]
      }
    }),
    LocalizeRouterModule.forRoot(routes, {
      parser: {
        provide: LocalizeParser,
        useFactory: (translate, location, settings, http) =>
            new LocalizeRouterHttpLoader(translate, location, settings, http),
        deps: [TranslateService, Location, LocalizeRouterSettings, HttpClient]
      }
    }),
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

export function HttpLoaderFactory(http: HttpClient) {
  return new TranslateHttpLoader(http);
}
0 Answers
Related