Open zewa666 opened 9 years ago
Cool! I'll give it some thought and try to take a closer look soon. I think it'd be good to try to keep as much of this out of the router as possible, and instead try to make it more flexible and extensible to allow the plugin to provide the customized behavior.
Couple random thoughts...
'lang?/users/:id'
to make the language segment optional, matching both "es/users/123" and "users/123". We'd probably still need some hook to let the plugin read the mapped route parameters.{ route: 'welcome', constraint: (fragment, params => currentLang == 'en') }
. There are other issues with duplicate routes, though...GlobalizedRouter
.@bryanrsmith you had any chance to look at this?
Unfortunately not. I had just started to look at implementing optional route parameters, but haven't written any code yet. There has been a steady stream of fairly important router issues that have been occupying all my time. At this point I'm not sure when I'll be able to get to it-- it'll probably take me a few weeks to get through the current high-priority router cases.
@bryanrsmith talked to you on private gitter about the help for this issue. We need to figure out the best approach to make existing routes translatable. So far my idea was to create duplicates of existing routes but that would create some issues with custom elements like the nav-bar, where you'd have additional logic to check when to show what version of the route.
So there might be a better approach to this. Potentially something along a custom navigation provider, which would check additional properties of the route.
Here are the community feature requests (from the Wiki https://github.com/aurelia/framework/wiki/Ideas-for-an-i18n-module):
Additionally I'm not sure how much of that should be part of the router itself and what belongs to the plugin. So I've added you as collaborator in case you need to try out things and modify stuff.