angular-l10n
angular-l10n copied to clipboard
Lazy loading with initialNavigation enabled
I am getting a weird error, as well, when lazy loading translations from a project created with nx.
core.js:6189
ERROR Error: Uncaught (in promise): angular-l10n (formatLanguage): Invalid language
at resolvePromise (zone-evergreen.js:798)
at resolvePromise (zone-evergreen.js:750)
at zone-evergreen.js:860
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Object.onInvokeTask (core.js:41442)
at ZoneDelegate.invokeTask (zone-evergreen.js:398)
at Zone.runTask (zone-evergreen.js:167)
at drainMicroTaskQueue (zone-evergreen.js:569)
What's weird, is that it works fine with the exact same code when I just create a project with the Angular CLI.
- Repo for the ng version
- StackBlitz project for the ng version
- Repo for the nx version
- (non-functioning) StackBlitz project for the nx version
Looks like there might be some issues with running an Nx project in StackBlitz. Here is a pristine project that was generated with nx on StackBlitz.
If this can't be figured out, I'm going to move away from using Nx. I like it, but I think I can get most of what I want done with just the Angular CLI (multiple projects / libraries).
Originally posted by @nickroberts in https://github.com/robisim74/angular-l10n/issues/295#issuecomment-612272480
@nickroberts Your app built with nx has a difference: use initialNavigation: 'enabled' in the router: if I remove it, the app works (also the reloading of the lazy module).
However, it should work also with initial navigation, so there must be something else in the app, but it doesn't depend on nx anyway.
Ah! That's it! At least as to why the Nx one doesn't work.I added that to the ng version, and it broke, too. Thanks for the insight! Might need to look into why that option isn't working for angular-l10n.
Thanks! Also, thanks for migrating this to a separate issue. I guess you can either close this, or if you want to investigate why that option is breaking the library, that's cool.
Keep up the great work!
Looks like that property is required for SSR to work.
https://angular.io/api/router/InitialNavigation
Looks like the router has its own APP_INITIALIZER, as well.
https://github.com/angular/angular/issues/36263#issuecomment-610671572
The strange thing is that in the sample app of this project, the option works (but without L10nRouting).
About SSR, never used that option.
However I'll continue to investigate, and let you know here.
Greetings
Yea, I haven't used Angular Universal (SSR), either, but would love to be able to use that option if we need to. I'll let you know if I find out anything else. Thanks!
@nickroberts I fixed initialNavigation in the latest version: https://github.com/robisim74/angular-l10n/releases/tag/v9.2.0
Greetings
@robisim74 It looks like this is back with version 10.0.1. 10.0.0 works, but after updating, and lazy loading translations, it no longer loads the lazy loaded translations ifinitialNavigation is enabled.
@nickroberts Thanks for reporting the problem (again). Fixed in v10.0.2
Looks good! Thanks!
Closed due to inactivity