question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EXCEPTION: No provider for TranslateStore!

See original GitHub issue

I’m submitting a … (check one with “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 Throw exception : EXCEPTION: No provider for TranslateStore!

Expected/desired behavior Do the right translation

Reproduction of the problem If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar. You can use this template as a starting point: http://plnkr.co/edit/tpl:01UjWY3TKfP6pgwXKuEa

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • ngx-translate version: 6.0.0

  • Angular version: 2.4.7

  • Browser: [Chrome XX | Firefox XX ]

Import TranslateModule from AppModule:

` import { TranslateModule, TranslateLoader, MissingTranslationHandler } from “@ngx-translate/core”; import { MyMissingTranslationHandler } from ‘./i18n/missing-trans.handler’; import { TranslateHttpLoader } from ‘@ngx-translate/http-loader’; import { Http } from ‘@angular/http’;

export function HttpLoaderFactory(http: Http) { return new TranslateHttpLoader(http, ‘./i18n/lang’, ‘-lang.json’); }

@NgModule({ declarations: [ AppComponent, ], imports: [ SharedModule, BaseModule, AccountModule, TranslateModule.forChild({ loader: { provide: TranslateLoader, useFactory: (HttpLoaderFactory), deps: [Http] }, missingTranslationHandler: { provide: MissingTranslationHandler, useClass: MyMissingTranslationHandler } }) ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } `

And then export it in the sharedModule:

` import { TranslateModule } from “@ngx-translate/core”;

@NgModule({ imports: [ CoreModule, TranslateModule.forChild() ], declarations: [ MessageComponent, MaxLengthExtValidatorDirective, FilterComponent ], exports: [ CoreModule, MessageComponent, MaxLengthExtValidatorDirective, FilterComponent, TranslateModule ], providers: [SessionService, MessageService] }) export class SharedModule {

} `

Not do any translation yet, it already throw the exception. If did not export it in the sharedModule, then there is no exception, but the ‘translate’ pipe will not be found.

Any suggestion?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

25reactions
AbdallahBedircommented, Jan 5, 2018

The solution for me is importing “TranslateModule.forChild” in the SharedModule and importing “TranslateModule.forRoot” in the AppModule

17reactions
steven-zoucommented, Feb 24, 2017

Sorry, find the problem, forgot to change “TranslateModule.forChild” to “TranslateModule.forRoot” in the AppModule. Will close it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: No provider for TranslateStore - Stack Overflow
Try this: import {TranslateFakeLoader,TranslateLoader,TranslateModule,TranslateService } from '@ngx-translate/core'; TestBed.
Read more >
Angular testing-->No provider for TranslateStore!
Angular testing-->No provider for TranslateStore! ; 1. import {TranslateFakeLoader,TranslateLoader,TranslateModule,TranslateService } from '@ngx-translate/core';.
Read more >
Nullinjectorerror: No Provider For Translate Service - ADocLib
I am using ng2translate to localize my ionic 2 app But i am getting this runtime exception 1 TranslateLoader 2 175607 error EXCEPTION:...
Read more >
Ngx-translate NullInjectorError: No provider for Injector!
Hi, I am trying to import the utility module from another ionic app to my current one. The utils module has TranslateModule as...
Read more >
EXCEPTION: Error: Uncaught (in promise): No provider for ...
EXCEPTION : Error: Uncaught (in promise): No provider for AuthenticationService! I'm stuck on this one error. I'm not sure what I'm doing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found