gilsdav / ngx-translate-router

Translate routes using ngx-translate
130 stars 44 forks source link

Translated route child wildcard routes #104

Open AntonVandeghinste opened 3 years ago

AntonVandeghinste commented 3 years ago

Hello

This is more of a question than it is an issue. Regarding wildcard routes, I have seen issue #36. I also see the mention about it in the README.

However, in some cases we would want a child route to be a wildcard (within a certain component for example). Stated the fact it is impossible to know from a wildcard route, if the language is present or not, when a child wildcard route is on a translated parent, wouldn't you know for a fact the language is present?

Simplified example:

const routes: Routes = [
  { path: 'BankAccount/:accountNumber', component: BankAccountComponent,
    children: [
      { path: '', component: OverviewComponent},
      { path: 'STATEMENTS', children: [
        { path: '', component: StatementsOverviewComponent},
        { path: 'SEARCH_STATEMENTS', component: SearchStatementsComponent },
        { path: '**', component: QuarterlyViewStatementsComponent }
      ]},
  ]},
];

(NOT a real example) Say on OverviewComponent, you have N quarters lined to choose from with `[routerLink]="['BankAccount', myAccountNumber, 'Statements', 'QxYYYY'] | localize", where x is a number from 1 to 4.

Say we don't do custom url matching, we defer to a QuarterlyViewStatementsComponent when the url is not SEARCH_STATEMENTS.

To make matters worse: Say we use history.state in QuarterlyViewStatementsComponent to retrieve some stuff from the routerlink, Would the redirectTo solution mentioned in the README still work?

This seems to me like a situation, where it would be possible to determine the language, AND support the wildcard routes, but if and only when the wildcard route is a child of an already translated route.

Suggestion maybe? Let me know.

gilsdav commented 2 years ago

Hello @AntonVandeghinste , Sorry for the delay. Do you still need help ?

AntonVandeghinste commented 2 years ago

We worked around it by doing a little bit of manual navigation I think. The suggestion (based on issue #36 where one is unable to change the language, because there's no indication if the language is present in the url) was just that whenever you have a wildcard route as child of a translated route you would know for a fact that the language is there.

I was facing this specific case, where in a wildcard child route i was unable to change the language.

I also haven't followed up on latest development, so if this is already a thing , or has been fixed/changed, you can safely close this thread.

Thanks!