Skip to content

I18n configuration for angular19 standalone components seems to be broken #561

@brankoiliccc

Description

@brankoiliccc

I have recently updated my project to angular 19.

All examples I could find still reference module type configuration.

i18n configuration in main.ts or component#providers array does nothing. It defaults to zhHans

    selector: 'app-gantt-tab',
    templateUrl: './gantt-tab.component.html',
    styleUrls: ['./gantt-tab.component.scss'],
    imports: [        
      CommonModule,
      MatCardModule,
      MatButtonModule,
      MatChipsModule,
      MatIconModule,
      MatMenuModule,
      MatProgressSpinnerModule,
      FormsModule,
      NgxGanttModule,
      MatTableModule,
      MatSelectModule,
      DragDropModule,
      IconModule,
      ],
    standalone: true,
    providers: [
      GanttPrintService,
      { provide: GANTT_I18N_LOCALE_TOKEN, useValue: [{ locale: GanttI18nLocale.enUs }] },
      {
        provide: GANTT_GLOBAL_CONFIG, useValue: {
          locale: GanttI18nLocale.enUs,
          linkOptions: {
            dependencyTypes: [GanttLinkType.fs],
            showArrow: false,
            lineType: GanttLinkLineType.curve
          },
          styleOptions: {
            headerHeight: 44,
            lineHeight: 44,
            barHeight: 22
          },
          dateOptions: {
            weekStartsOn: 1
          }
        }
      },
    ]
})
export class GanttTabComponent implements OnInit {

and main.ts

bootstrapApplication(AppComponent, {
  providers: [
    importProvidersFrom(BrowserModule, RouterModule, AppRoutingModule, MaterialModule, IconModule, MatDatepickerModule, MatMomentDateModule, ResponsiveTableModule, NgxMatSelectSearchModule, NgChartsModule),
    { provide: ErrorHandler, useClass: PlatformErrorHandler },
    { provide: HTTP_INTERCEPTORS, useClass: PlatformRequestInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: GatewayInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: XsrfInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: SpinnerInterceptor, multi: true },
    { provide: REMOVE_STYLES_ON_COMPONENT_DESTROY, useValue: false },
    { provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } },
    provideAppInitializer(() => {
      const initializerFn = (appInit)(inject(AppInitializeService));
      return initializerFn();
    }),
    { provide: LOCALE_ID, useFactory: localeFactory },
    { provide: APP_BASE_HREF, useFactory: localeBaseHrefFactory, deps: [LOCALE_ID] },
    { provide: GANTT_I18N_LOCALE_TOKEN, useValue: [{ locale: GanttI18nLocale.enUs }] },
    {
      provide: GANTT_GLOBAL_CONFIG, useValue: {
        locale: GanttI18nLocale.enUs,
        linkOptions: {
          dependencyTypes: [GanttLinkType.fs],
          showArrow: false,
          lineType: GanttLinkLineType.curve
        },
        styleOptions: {
          headerHeight: 44,
          lineHeight: 44,
          barHeight: 22
        },
        dateOptions: {
          weekStartsOn: 1
        }
      }
    },



    // { provide: 'gantt-i18n-locale', useValue: GanttI18nLocale.enUs}, 
    provideHttpClient(withInterceptorsFromDi(), withXsrfConfiguration({
      cookieName: 'XSRF-TOKEN',
      headerName: 'X-XSRF-TOKEN'
    })),
    provideAnimations()
  ]
});
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions