#How to make a translation for Qwik url routes?

10 messages · Page 1 of 1 (latest)

cedar ginkgo
#

Currently, I am using Qwik-Speak to translate. I have to make translation for a whole Qwik app, including URL routes. For example:
src/
└── routes/
├── about-us/
│ └── index.tsx # https:/.../en-US/about-us in Eng or https:/.../om-oss in Swedish
└── layout.tsx
So what is the best practice to dynamically translate url route /about-us to /om-oss after switching to another language? And, of course, to save the functionality of the route.

P.S. The appearing of en-US in https:/.../en-US/about-us I figured out by using Qwik-Speak lib.

onyx lily
#

I'm curious to see if anyone has any input on this. Technically speaking it should be possible, but I have no idea what best practices are. My initial thought would be to make two versions of the site, with each of their own folders to denote the routing. However I'm pretty sure you're more looking for a programmatic way of doing it. I imagine it be something like keeping a json file that denotes the translated routes, then have a routeloader that checks if the entered url path matches any of the translations, and then tells the site which language to render based on that. But that's very much just a "what came to mind" kinda answer, I have no clue if this is optimal at all. I'm also writing to bump the question and hopefully see a "correct implementation" at some point.

hollow quarry
onyx lily
cedar ginkgo
hollow quarry
#

This could be a github issues in this case

balmy marsh
hollow quarry
#

How well does this feature integrate with @angular/localize* library ? Won't there be conflicts with the prefix in the parameter of rewriteRoutes ?

balmy marsh
#

So, I think it should work. $localize can run in runtime mode. So you should be able to use it in vite.config to rename the routes. I think you would have to do some tricks to make it work with all of the translation (not just one.) But I think it should work in theory.