robisim74 / angular-l10n

Angular library to translate texts, dates and numbers
MIT License
380 stars 59 forks source link

How to use route parameters when using custom L10nTranslationLoader #312

Closed mirinkinen closed 4 years ago

mirinkinen commented 4 years ago

I have some custom route data in the URL that is needed when fetching translations. Any ideas how I can use route data when the L10nTranslationLoader.get method is called? It seems that this method is called so early in the lifecycle that I don't have any route events available.

I tried to defer the initialization of this module but it caused weird behavior: the locale was missing. I also tried to defer the execution using rxjs Subject with bad outcome.

In the meantime, I'm going to look for if this L10nRoutingModule could somehow help me...

robisim74 commented 4 years ago

Yes, see L10nRoutingService: Router& Location are not available during APP_INITIALIZER, so you have to use Injector to get them.