transloco: Does not work as root in lazy loaded module

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

When loaded in root or directly connected module, it works fine but when loaded as lazy module there is a problem:

taticInjectorError(AppModule)[TranslocoService -> InjectionToken TRANSLOCO_TRANSPILER]: 
    StaticInjectorError(Platform: core)[TranslocoService -> InjectionToken TRANSLOCO_TRANSPILER]: 
      NullInjectorError: No provider for InjectionToken TRANSLOCO_TRANSPILER!
NullInjectorError: StaticInjectorError[I18nService -> TranslocoService]: 
  StaticInjectorError(AppModule)[TranslocoService -> InjectionToken TRANSLOCO_TRANSPILER]: 
    StaticInjectorError(Platform: core)[TranslocoService -> InjectionToken TRANSLOCO_TRANSPILER]: 
      NullInjectorError: No provider for InjectionToken TRANSLOCO_TRANSPILER!

Expected behavior

works not only as imported in static module

Minimal reproduction of the problem with instructions

same as https://github.com/ngneat/transloco/issues/152. I have also tried to use TranslocoService as an own provider from useFactory, but it is not used. Maybe the cause is provideIn: 'root'?

What is the motivation / use case for changing the behavior?

I am creating application/library which have translation module configured before usage. Configuration is not predefined, and may be different

Environment


Angular version: 8.2.14
transloco: 2.3.15


Browser:
- [x] Chrome (desktop) version 80.0.3987.122
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v12.13.1
- Platform: windows

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 51 (5 by maintainers)

Most upvoted comments

do we have any update on support for microfrontend based approach where the lazy loaded module needs to have access to the transloco context ? Thanks.

This is in fact a real world problem that can happend in a micro frontend architecture where each remote needs to provide its own translations. Any chance to get micro frontend support where each micro frontend (lazy loaded module) can have its own transloco instance?

@Azbesciak no worries, just give an update as soon as you get the chance to check it and we will take it from there 🙂