diff --git a/apps/transloco-playground/src/app/lazy-multiple-scopes/lazy-multiple-scopes.component.ts b/apps/transloco-playground/src/app/lazy-multiple-scopes/lazy-multiple-scopes.component.ts index 32063ea6d..89eabfa95 100644 --- a/apps/transloco-playground/src/app/lazy-multiple-scopes/lazy-multiple-scopes.component.ts +++ b/apps/transloco-playground/src/app/lazy-multiple-scopes/lazy-multiple-scopes.component.ts @@ -7,8 +7,7 @@ import { TranslocoModule, provideTranslocoScope } from '@jsverse/transloco'; templateUrl: './lazy-multiple-scopes.component.html', styleUrls: ['./lazy-multiple-scopes.component.scss'], providers: [ - provideTranslocoScope({ scope: 'admin-page', alias: 'AdminPageAlias' }), - provideTranslocoScope({ scope: 'lazy-page', alias: 'LazyPageAlias' }), + provideTranslocoScope({ scope: 'admin-page', alias: 'AdminPageAlias' }, { scope: 'lazy-page', alias: 'LazyPageAlias' }), ], standalone: true, imports: [TranslocoModule], diff --git a/docs/docs/lazy-load/scope-configuration.mdx b/docs/docs/lazy-load/scope-configuration.mdx index 273ff1b15..0e36d2b99 100644 --- a/docs/docs/lazy-load/scope-configuration.mdx +++ b/docs/docs/lazy-load/scope-configuration.mdx @@ -45,6 +45,21 @@ export const TODO_ROUTES: Route = { ``` +We also can provide several scopes at once: + +```ts title="core.module.ts" +import { Route } from '@angular/router'; +import {provideTranslocoScope} from "./transloco.providers"; + +export const TODO_ROUTES: Route = { + path: '', + loadComponent: () => import('./todos.component').then((TodosComponent) => TodosComponent), + providers: [ + provideTranslocoScope('todos', { scope: 'shared', alias: 'sharedAlias' }), + ], +}; +``` + diff --git a/libs/transloco/src/lib/transloco.providers.ts b/libs/transloco/src/lib/transloco.providers.ts index ef2cc65b1..442063b08 100644 --- a/libs/transloco/src/lib/transloco.providers.ts +++ b/libs/transloco/src/lib/transloco.providers.ts @@ -76,12 +76,12 @@ export function provideTranslocoLoader(loader: Type) { ]); } -export function provideTranslocoScope(scope: TranslocoScope) { - return { +export function provideTranslocoScope(...scopes: TranslocoScope[]) { + return scopes.map((scope) => ({ provide: TRANSLOCO_SCOPE, useValue: scope, multi: true, - }; + })); } export function provideTranslocoLoadingTpl(content: Content) {