From 9509b0ca862a66ef355dee47f314659aa63d6e78 Mon Sep 17 00:00:00 2001 From: Pascal Weyrich Date: Mon, 11 Aug 2025 11:06:15 +0200 Subject: [PATCH 1/2] refactor: add forRoot method to L10nIntlModule BREAKING CHANGE: L10nIntlModule doesn't ship with a provider for L10nIntlService anymore. Use L10nIntlModule.forRoot() instead to include a provider for L10nIntlService. --- .../src/lib/modules/l10n-intl.module.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/projects/angular-l10n/src/lib/modules/l10n-intl.module.ts b/projects/angular-l10n/src/lib/modules/l10n-intl.module.ts index 568147a..47c786d 100644 --- a/projects/angular-l10n/src/lib/modules/l10n-intl.module.ts +++ b/projects/angular-l10n/src/lib/modules/l10n-intl.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { L10nDatePipe, L10nDateAsyncPipe } from '../pipes/l10n-date.pipe'; import { L10nNumberPipe, L10nNumberAsyncPipe } from '../pipes/l10n-number.pipe'; @@ -47,6 +47,14 @@ import { L10nIntlService } from '../services/l10n-intl.service'; L10nPluralDirective, L10nDisplayNamesDirective ], - providers: [L10nIntlService] }) -export class L10nIntlModule { } +export class L10nIntlModule { + + public static forRoot(): ModuleWithProviders { + return { + ngModule: L10nIntlModule, + providers: [L10nIntlService] + }; + } + +} From a96004450c37785c5926e2365131ee0a9ebafce2 Mon Sep 17 00:00:00 2001 From: Pascal Weyrich Date: Mon, 11 Aug 2025 11:17:58 +0200 Subject: [PATCH 2/2] fix tests --- projects/angular-l10n/src/tests/l10n-date.directive.spec.ts | 2 +- projects/angular-l10n/src/tests/l10n-intl.service.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/angular-l10n/src/tests/l10n-date.directive.spec.ts b/projects/angular-l10n/src/tests/l10n-date.directive.spec.ts index a03f9c6..ff836f3 100644 --- a/projects/angular-l10n/src/tests/l10n-date.directive.spec.ts +++ b/projects/angular-l10n/src/tests/l10n-date.directive.spec.ts @@ -46,7 +46,7 @@ describe('L10nDateDirective', () => { declarations: [MockComponent], imports: [ L10nTranslationModule.forRoot(config), - L10nIntlModule + L10nIntlModule.forRoot() ] }).createComponent(MockComponent); comp = fixture.componentInstance; diff --git a/projects/angular-l10n/src/tests/l10n-intl.service.spec.ts b/projects/angular-l10n/src/tests/l10n-intl.service.spec.ts index d5bb128..4c5194a 100644 --- a/projects/angular-l10n/src/tests/l10n-intl.service.spec.ts +++ b/projects/angular-l10n/src/tests/l10n-intl.service.spec.ts @@ -33,7 +33,7 @@ describe('L10nIntlService', () => { TestBed.configureTestingModule({ imports: [ L10nTranslationModule.forRoot(config), - L10nIntlModule + L10nIntlModule.forRoot() ] }); loader = TestBed.inject(L10nLoader);