Closed MichaelKohler closed 6 years ago
I'm facing a few challenges here, still learning my way around React architecture. :) Let me list the initial requirements here first:
/de-DE/activities
/activities
and /en-US/activities
are the same.I thought I can can use optional parameters to take the language in the URL or not.
<Route path='/:lng?/activities' component={ActivitiesPage}/>
This works well for /en-US/activities
, but does not render the activity page (but the index page) for /activities
. :( One way to solve this that I've found is to duplicate the routes, but that's not really something I want to do if there are better ways..
If we get the above to work, we should update the language for Fluent depending on the URL lang
param. I'd be tempted to use Redux for the state and dispatch a "LANGUAGE_CHANGE" action for this (as well as use that when the user manually switches the language). However, where would I dispatch it for the URL? The Router would render every component, and I'm not keen to dispatch this in every single component. Any thoughts would be appreciated :)
If the user chooses de-DE
or comes in via /de/
all the links on the page should be prefixed with /de
. The ReactRouter basename
is not dynamic, so that's not an option. Another option would be to read out the current language from the store and prefix it on every link. Not particularly ideal either. Are there better ways?
If the user manually switches the language, the URL should probably be rewrittten. That one is probably a normal URL rewrite which should not be too hard. Need to check this out.
Any thoughts on this would be greatly appreciated :)
The manual language switching is now living in https://github.com/MichaelKohler/activate-rewrite/issues/32
We should allow language links such as /en-US/subsite or /es/subsite which then directly switch the language to the requested language. If the language is not available, it should fall back to EN.