1

In app.module.ts has the following provider:

{
    provide: LOCALE_ID,
    useFactory: (translate: TranslateService) => translate.currentLang,
    deps: [TranslateService]
}

I have updated angular version from 8.2 (iteratively to 12). Everything worked on version 8.2, but now undefined is always written to LOCALE_ID.

But if I change the code to:

{
    provide: LOCALE_ID,
    useValue: 'en'
}

Then everything works, from here I conclude that the problem in useFactory, but there are no ideas how to fix it.


Additionally, if it is important:

  1. I am using ngx-translate 13.0.0
  2. In services and pipes, I get the parameter as follows:
constructor(@Inject(LOCALE_ID) private locale: string)
  1. Also TranslateService is undefined in the AppModule class, although in other places of the application, after loading it is available

SOLVED: The question was solved, the transfer of the provider from app.module to app.component helped

ArtoriasDF
  • 19
  • 2
  • If you solved your issue, you can self-answer and accept it to share how you fix it. – Elikill58 Oct 03 '21 at 08:46
  • Please post an answer so that we can tell that is is solved without having to load the page. Thanks. Glad you worked it out. – Nate T Oct 03 '21 at 09:04

0 Answers0