Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Hsinky opened this issue Mar 14, 2024 · 0 comments
Open

Comments

@Hsinky
Copy link

Hsinky commented Mar 14, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant