-
Notifications
You must be signed in to change notification settings - Fork 2
How to use in Angular 16 standalone components? #14
Comments
That should be enough for basic setup. The url though should be |
@penleychan thank you for such a fast reply! I wasn't aware that I needed to add the language slug in the route, I guess now I'm a little closer to get it working hehe :) However, http://localhost:4300/es/acceder doesn't seem to work as well, I get the same type of message in the console. I tried to build a new angular 16 standalone app from scratch just in case this seed template had something interfering, but I can't get it to work there as well. Any ideas? Thank you so much again. |
Sorry, I'll have to get back to you later on this, currently on vacation. |
Hello, sorry for the delay, I am now back from my break. I've created an example for ng17 standalone, which should basically be the same as ng16. Looks like you were just missing |
Hi!! First of all thank you so so much for your help, really appreciated. And sorry for coming back so late for feedback. I tried your suggested change and it worked! ... somehow. There's a few things that made me struggle, not critical though. First thing is that this starter kit I'm using defined the available languages for transloco this way:
And this made the code break at the
I don't know though if this is more related to the transloco plugin or your routing addon? The second thing is that after the first change it still didn't work as expected, it gave me another error:
Looking in forums I got to a similar issue hinting that there might be some problem defining the route.
However if I directly point to the component skipping the layout component it then works! EDIT: I just checked again and child routes per se also work, the problem seems to be in the loadChildren() stuff for lazing-loading routes. Finally, this maybe is not a dealbreaker but I observed that the default language routes also need the language slug, or at least they do on my setup, Sorry for so many questions! And thank you again. |
On initialization library leverages transloco
Both method above accepts Migrating the component that changes locale based on At this moment in time, I do not have any plan to add support for As for your routing it seems off: Similarly if you're doing standalone you would use Skip Route Localization is supported, you can have a look at the gilsdav documentation on it since this is just a port of the library: https://github.com/gilsdav/ngx-translate-router#excluding-routes Only thing to note based on your example is that those So your "Auth routes for guests" would look like:
Hope that helps |
Sorry if this is too basic and not an issue really but I'm quite new to Angular and there's not much documentation about this plugin also.
I'm migrating an existing Angular 9 app to a new Angular 16 seed project that uses standalone components and I'm not sure what should be the setup.
I have a
app.config.ts
file with the following:In
app.routes.ts
:And I also added the route translations to
es.json
file, example:But still if I access
http://localhost:4300/acceder
I get the following error on the browser console:I guess I need this glue:
´´´
imports: [
RouterModule.forRoot(routes),
LocalizeRouterModule.forRoot(routes)
],
´´´
But I don't know how to set it up without the @NgModule stuff.
Any help would be very much appreciated.
Thanks!
The text was updated successfully, but these errors were encountered: