localize-router
localize-router copied to clipboard
import order manage issues
Hello,
I have issues in the two possible import orders.
First look
-
If I put
RouterModule before LocalizeRouterModule
I have issues with ReactiveFormModule in Angular Universal and lazyloaded routes are not translated in server side. -
If I put
LocalizeRouterModule before RouterModule
everything works fine if I don't need to translate lazyloaded child routes. But if i do, It doesn't works on client and server side.
So it's not possible to have a fully works project with Universal.
My repo (translated-url branche) : https://github.com/gilsdav/angular-universal-localize-router/tree/translated-url
If you start the project, you can see that "http://localhost:4200/fr/heros/home" works but not "http://localhost:4200/fr/heros/accueil" and if you change imports order in app-routing.module.ts
"http://localhost:4200/fr/heros/accueil" works.
So "heroes" is translated to "heros" (main routes) but not childs (initChildRoutes is never called).
Tested with bearkpoints: LocalizeRouterConfigLoader is not created and it load
function is not called when "LocalizeRouterModule" is firstly imported.
Second look
Without ReactiveForms and imports in first order RouterModule before LocalizeRouterModule
, "http://localhost:4200/fr/heros/accueil" only works in front but not in SSR.
Is it @nguniversal/module-map-ngfactory-loader
compatible ? This module is used to manage lazyload of modules in SSR.
I already have the problem in master branch version.
Solution
I created a module loader that is a merge between yours and the Universal one: https://github.com/gilsdav/universal-localize-module-loader
Hi @gilsdav, this is amazing and simple solution. I would ask you kindly to create a full compiled package for this solution.
If you need help, let me know.
I can also add it on our org and grant you full access to that repo.
Hello @meeroslav, you are right I will update my repo to create a npm package. It will be more easy to use.
@meeroslav done on my repo : https://github.com/gilsdav/universal-localize-module-loader and on NPM : https://www.npmjs.com/package/localize-router-lazy-universal-module-loader . I chose a name that fits better with your library. Thank's again for your amazing works on this lib.