Here is my problem. I have to set up routing in Angular so that in URL there will be a country code and a language. for example
https://example.com/usa/en
The tricky part is that this localization parts can change so I have a button to switch country and language so it will be /gb/en or /usa/fr.
How can I get it working like this using localize-router and ngx-translate.
Any help much appreciated.
Pardon me if I got your question wrong, but if I understand it correctly you can follow below approach:
In your AppRoutingModule configure routes as below:
const routes: Routes = [
{
path:'' , pathMatch: 'full', component: SomeComponent,
children: [
{ path: ':country-code/:lang-code' , component: SomeOtherComponent }
]
}
]
You can now redirect by your button click event and it changes country-code and lang-code accordingly and you can retrieve these values in your SomeOtherComponent to perform related tasks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With