Closed PauAbellaMolina closed 4 months ago
Hi!
I have already prepared a PR https://github.com/gilsdav/ngx-translate-router/pull/161 to support Angular 18 and specifically your request because if you try to use a function now, the library crashes. Maybe @gilsdav can have a look to it and merge it :)
However, I would like to point that your issue helped to improve the documentation of the PR because it is easy to think that the result of the "redirectTo" function might be automatically translated as any other route as you expect in your example, but it is not actually possible with this library because router is statically translated at the start of the application and this function is dynamically evaluated every time the user navigates, so we are in different translation contexts. In order to translate the routes you should inject the router translate service and return a translated route. I added an example in the PR to help anyone trying to use an example like yours. You can check it out here: https://github.com/gilsdav/ngx-translate-router/pull/161/commits/06fab2362c9af87735cb2c124c226339be32dd37#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R469
Note that my example will only work with the PR applied, as internal changes in the library are required to accept redirectTo functions.
Great! I'll make the changes you suggested and wait for the PR to be merged then!
Thanks.
Published as version 7.2.1
Hi there!
I just upgraded my project to Angular 18 and it seems like the redirectTo with a function is not working. Not sure if that's the only thing not working about the new Angular 18 stuff, I didn't have the time to test any further.
My particular piece of code:
Thanks.