meeroslav / universal-localize-example

2 stars 0 forks source link

Update demo to new version of Angular Universal? #3

Open chin2km opened 4 years ago

chin2km commented 4 years ago

Any plan to update the demo to use new version of Angular?

meeroslav commented 4 years ago

Unfortunately, the localize-router does not work with Angular 8 (or upcoming 9) due to deep braking changes in the router. In order to make it work a sever hack would have to be applied, which at the moment I'm not happy with. You can check at @gilsdav solution at https://www.npmjs.com/package/localize-router-lazy-universal-module-loader. That should work as far as I know

gilsdav commented 4 years ago

Thank's @meeroslav,

I have a repo that show an example that is currently compatible with Angular 9 too: https://github.com/gilsdav/angular-universal-localize-router

The library you indicate is no longer useful from Angular 8 using my fork (https://github.com/gilsdav/ngx-translate-router) and there are some new features.

chin2km commented 4 years ago

@gilsdav I tried your library and it works (mostly) for me :) Good job! My requirement is to have routes like: site.com/ch/fr or site.com/ch/de (thats switzerland in french and german).. so basically the language is not the first path after the top-level-domain.. Do you think your library has an out of the box solution for this? or I'll have to find a way a workaround..?

@meeroslav thanks for the update 👍🏻

gilsdav commented 4 years ago

@chin2km Is /ch/ a path managed by your application (in router) or is it a physical path ?

1.

If "ch" can be part of your translations, you can add a subfolder of your "locales" folder that contains your locales. -> locales ---> ch ------> fr.json ------> de.json and use this.localize.changeLanguage('ch/fr');

2.

If it's a physical path on your server you can use --base-href=/ch/ on CLI.

3.

If you use it in your router (with a component at this level), I don't think this is currently possible. If you don't have a attribute "component" on this path, can't you use the first point ?

const routes = [
    {
        path: 'ch',
        component: ChComponent,
        children: [
            ...
        ]
    }
];