Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about routes without language prefix is present #157

Open
breakiboy opened this issue Dec 26, 2023 · 0 comments
Open

Question about routes without language prefix is present #157

breakiboy opened this issue Dec 26, 2023 · 0 comments

Comments

@breakiboy
Copy link

Hi Guys,

I have an application that's already been propagated and has numerous backlinks. Currently, I'm implementing ngx-translate and ngx-translate-route.

The implementation wasn't easy for me, but it's working now. However, I'm facing a problem:

When external users access the old URLs without a language prefix, the application fails to recognize the routes. Is there an easy workaround for this?

Below is a snippet of my routing code. The issue arises because I'm only using lazy-loaded modules within a layout component.

const routes: Routes = [
  {
    path: '',
    redirectTo: '/home',
    pathMatch: 'full'
  },
  {
    path: '',
    component: HomeLayoutComponent,
    children: [
      {
        path: 'home',
        loadChildren: () => import('./modules/home/home.module').then(m => m.HomeModule)
      },
      {
        path: 'ads',
        loadChildren: () => import('./modules/ads/ads.module').then(m => m.AdsModule),
        data: { skipRouteLocalization: true }
      },
      {
        path: 'tags',
        loadChildren: () => import('./modules/tags/tags.module').then(m => m.TagsModule)
      },

I'm seeking a solution to automatically append a default prefix to the URL when no prefix is present. I'm not using SSR; the application is entirely client-side, and I use nginx on the server side.

I'd prefer to resolve this issue internally within Angular, as I want to avoid using a 301 redirect in nginx. Is there an experienced herowho can assist me?

routes on app works fine with [routerLink]="'/maps' | localize" its only about external links.

Kind Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant