I'm submitting a
[ ] feature request
Current behavior
When I change language using a button click on UI , Its working amazing but the URL is not at all changing to current language.
Lets say I change the language to ru , the URL still remain same ( htttp://localhost:4200 )
Expected/desired behavior
It will be really nice If we can get the ability to manipulate the URL as traditional websites to something like, depending on the language we select through UI.
http://localhost:4200/en for English,
http://localhost:4200/ru for Russion .. and so on.
I thought of handle it using angular routing but managing it with routing will be a real mess to handlle when the project scales.
ngx-translate version: 9.0.2
Angular version: 5.0.0
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
In general I think this would be hard to implement as websites all have a different convention of representing the chosen language in the URL.
You can do it yourself by subscribing to language change events and then modifying the current url to reflect the chosen language using the Location object in the angular/common package:
translate.onLangChange().subscribe(trans => {
const path = this.location.path();
const modified_path = change path to reflect chosen language (trans.lang)
this.location.replaceState(modified_path);
})
Most helpful comment
In general I think this would be hard to implement as websites all have a different convention of representing the chosen language in the URL.
You can do it yourself by subscribing to language change events and then modifying the current url to reflect the chosen language using the Location object in the angular/common package:
translate.onLangChange().subscribe(trans => { const path = this.location.path(); const modified_path = change path to reflect chosen language (trans.lang) this.location.replaceState(modified_path); })