jsverse / transloco

🚀 😍 The internationalization (i18n) library for Angular

Home Page:https://jsverse.github.io/transloco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Maksclub opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

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

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