diff --git a/packages/core/src/application_ref.ts b/packages/core/src/application_ref.ts index 91e4a40e80..24f173fdf6 100644 --- a/packages/core/src/application_ref.ts +++ b/packages/core/src/application_ref.ts @@ -302,11 +302,6 @@ export class PlatformRef { if (!exceptionHandler) { throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?'); } - // If the `LOCALE_ID` provider is defined at bootstrap we set the value for runtime i18n (ivy) - if (ivyEnabled) { - const localeId = moduleRef.injector.get(LOCALE_ID, DEFAULT_LOCALE_ID); - setLocaleId(localeId || DEFAULT_LOCALE_ID); - } moduleRef.onDestroy(() => remove(this._modules, moduleRef)); ngZone !.runOutsideAngular( () => ngZone !.onError.subscribe( @@ -315,6 +310,11 @@ export class PlatformRef { const initStatus: ApplicationInitStatus = moduleRef.injector.get(ApplicationInitStatus); initStatus.runInitializers(); return initStatus.donePromise.then(() => { + if (ivyEnabled) { + // If the `LOCALE_ID` provider is defined at bootstrap then we set the value for ivy + const localeId = moduleRef.injector.get(LOCALE_ID, DEFAULT_LOCALE_ID); + setLocaleId(localeId || DEFAULT_LOCALE_ID); + } this._moduleDoBootstrap(moduleRef); return moduleRef; }); diff --git a/packages/core/test/application_ref_spec.ts b/packages/core/test/application_ref_spec.ts index 54c4ae825d..8639cbe0db 100644 --- a/packages/core/test/application_ref_spec.ts +++ b/packages/core/test/application_ref_spec.ts @@ -346,11 +346,9 @@ class SomeComponent { it('should wait for APP_INITIALIZER to set providers for `LOCALE_ID`', async() => { let locale: string = ''; - const promise = Promise.resolve().then(() => { locale = 'fr-FR'; }); - const testModule = createModule({ providers: [ - {provide: APP_INITIALIZER, useValue: () => promise, multi: true}, + {provide: APP_INITIALIZER, useValue: () => locale = 'fr-FR', multi: true}, {provide: LOCALE_ID, useFactory: () => locale} ] });