core: The pipe 'translate' could not be found

I’m submitting a … (check one with “x”)

[ x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior Translate does not work on the child components

Expected/desired behavior Translate does not work on the child components

Reproduction of the problem I am using translation pipe on the home page it works fine, but when i add it on the child component , it says The pipe ‘translate’ could not be found

I looked at this issue,

https://github.com/ngx-translate/core/issues/163

but when i import

{provide: PLATFORM_PIPES, useValue: TranslatePipe, multi: true}`

it is not supported with the angular version. How can i solve this issue?

Please tell us about your environment:

  • **ngx-translate version:**5.0.0

  • Angular version: 2.4.0

  • Browser: [all | Chrome XX

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15

Most upvoted comments

For those coming across the pipe translate could not be found, here are the steps you need to do in a nutshell to fix the issue when using in a different module.

  1. Have the translate module logic along with translate loader and translateFactory present in the app.module.ts TranslateModule.forRoot({ provide: TranslateLoader, useFactory: (http: Http) => new TranslateStaticLoader(http, './assets/i18n', '.json'), deps: [Http] }) ],

  2. In your shared.module.ts (or any other module), import and export the Translate module.
i.e.: Translate module should be a part of both the import and export arrays. Most answers in SO and github mention importing the module but not exporting it.

@NgModule({ imports: [ TranslateModule ], exports: [ TranslateModule]

Just keep app module with what you have. It configures ngx-translate and sets up all the services which is fine. And then in your sub-module, just import TranslateModule and it should work.

forChild is not available in the 5.x version that he’s using. Just importing the module (without calling forRoot on it) should work for the pipe/directive.

Not working!. I am using this plugin, and when I add ‘Something’ | translate in template of plugin not working

You should add in child module: TranslateModule.forChild({…})