jsverse / transloco

🚀 😍 The internationalization (i18n) library for Angular
https://jsverse.github.io/transloco/
MIT License
2.01k stars 195 forks source link

Bug(transloco): Loader with scope not working for NotFound route expression ** #724

Open Maksclub opened 11 months ago

Maksclub commented 11 months ago

Is there an existing issue for this?

Which Transloco package(s) are the source of the bug?

Transloco

Is this a regression?

No

Current behavior

Loader definition:

export const provideAppLangScope = () => {
  return provideTranslocoScope({
    scope: 'app',
    alias: 'app',
    loader: SUPPORTED_LANGUAGES.reduce((acc: HashMap<() => Promise<Translation>>, lang) => {
      acc[lang] = () => import(`./i18n/${lang}.json`);
      return acc;
    }, {})
  })
}

Routes definition:

 // working (on /not route)
  {
    path: 'not',
    loadChildren: () => import('./page.not-found/routes').then(m => m.ROUTES),
    providers: [
      provideAppLangScope(),
    ],
  },

// not working on /bla-bla-bla
  {
    path: '**',
    loadChildren: () => import('./page.not-found/routes').then(m => m.ROUTES),
    providers: [
      provideAppLangScope(),
    ],
  }

ROUTES definition:

export const ROUTES = [
  {
    path: '',
    loadComponent: async () => (await import(`./not-found`)).NotFoundComponent,
  },
] as Route[];

Expected behavior

loader for '**' route definition working correct

Please provide a link to a minimal reproduction of the bug, if you won't provide a link the issue won't be handled.

-

Transloco Config

No response

Please provide the environment you discovered this bug in

Transloco: ^6.0.0
Angular: 16
Node: v20.6.1
Package Manager: 9.8.1
OS: Mac OS

Browser

Chrome
Safari
Firefox

Additional context

No response

I would like to make a pull request for this bug

No

Maksclub commented 11 months ago

I provided provideAppLangScope() in NotFound component and it's working! Temporal solution for me