ngx-translate/core

Error: [$injector:unpr] Unknown provider: translateProvider <- translate

Hsinky opened this issue · 0 comments

package.json

"@angular/animations": "12.2.3",
"@angular/cdk": "12.2.3",
"@angular/common": "12.2.3",
 "@angular/compiler": "12.2.3",
 "@angular/core": "12.2.3",
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "^6.0.0",

app.module.ts

import { CommonModule } from '@angular/common';
import {HttpClient, HttpClientModule, HttpClientXsrfModule } from '@angular/common/http';
import { NgModule,APP_INITIALIZER } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { UpgradeModule } from '@angular/upgrade/static';
import { GioPendoModule, GIO_PENDO_SETTINGS_TOKEN } from '@gravitee/ui-analytics';
import { UIRouterUpgradeModule } from '@uirouter/angular-hybrid';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from "@ngx-translate/http-loader";

import { TranslationService } from './services/translation.service';
import { uiRouterStateProvider, uiRouterStateParamsProvider, currentUserProvider, ajsRootScopeProvider } from './ajs-upgraded-providers';
import { Constants } from './entities/Constants';
import { ManagementModule } from './management/management.module';
import { OrganizationSettingsModule } from './organization/configuration/organization-settings.module';
import { httpInterceptorProviders } from './shared/interceptors/http-interceptors';
export function translationInitializer(translationService: TranslationService) {
  return function () {
    return translationService.init('en');  
  };
}
@NgModule({
  imports: [
    CommonModule,
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    // Explicitly disable automatic csrf handling as it will not work for cross-domain (using custom csrf interceptor).
    HttpClientXsrfModule.withOptions({
      cookieName: 'none',
      headerName: 'none',
    }),
    TranslateModule.forRoot({
      defaultLanguage: 'en',
      loader: {
        provide: TranslateLoader,
        useFactory: (http: HttpClient) => new TranslateHttpLoader(http, './assets/i18n/'),
        deps: [HttpClient]
      },
    }),
   
  ],
  providers: [
    {
      provide: APP_INITIALIZER, 
      useFactory: translationInitializer, 
      deps: [TranslationService], 
      multi: true
   }
  ],
})
export class AppModule {
  constructor(private upgrade: UpgradeModule) { }

  ngDoBootstrap() {
    this.upgrade.bootstrap(document.documentElement, ['gravitee-management'], { strictDi: true });
  }
}

errro:
Error: [$injector:unpr] Unknown provider: translateProvider <- translate