respond-framework / rudy

Rudy Router - MVC style route async controller for react-redux applications.
MIT License
80 stars 8 forks source link

Translatable paths #64

Open klis87 opened 5 years ago

klis87 commented 5 years ago

Hi, I am heavy user of redux first router and cannot wait for this library to become stable and documented.

In the meantime, I am wondering whether you will support better a case from RFR issue I posted some time ago https://github.com/faceyspacey/redux-first-router/issues/94

Ideally it would be great if all translation logic could be encapsulated in a route configuration, so we would not need to worry about going from /en/home to /de/haus and vice versa, as home/haus could be calculated by this library based on and option/basename

then, /en/haus and /de/home would raise 404, and swithing basename when on /en/home from en to de would automatically recalculate url to /de/haus

hedgepigdaniel commented 5 years ago

Sure, It would be nice to support that if it can be done in a simple way.

I would probably start by writing some code that preprocesses a routesMap to get the behaviour you want (or as close as possible) and trying to find the minimum change that would support it in the router itself. I wonder if you can:

Check out some of the simple examples for middlewares (e.g. the set page title package). There's alot of flexibility there over what was possible in RFR and the middleware API is they key to it. Also check out the toPath/fromPath options and such, they work a little differently.

Let me know if you need any help - I know documentation is sparse but I'm happy to point you in the right direction :)

klis87 commented 5 years ago

Thx for detailed answer. When I have some time, I will to switch from RFR to Rudy and I will post the outcome how I solved multilang urls, I also agree that it would be best to use existing Rudy Api for this purposes, or with minimum adjustments, if not possible.