lephyrus / ngx-translate-messageformat-compiler

Advanced pluralization (and more) for ngx-translate, using standard ICU syntax which is compiled with the help of messageformat.js.
MIT License
93 stars 29 forks source link

Angular 9 Version support #53

Closed Sijoma closed 4 years ago

Sijoma commented 4 years ago

Hey guys,

we use the latest version (4.5.0) however after updating to angular 9 we receive the following error:

zone.js:699 Unhandled Promise rejection: Can't resolve all parameters for TranslateMessageFormatCompiler: (?). ; Zone: <root> ; Task: Promise.then ; Value: Error: Can't resolve all parameters for TranslateMessageFormatCompiler: (?). at getUndecoratedInjectableFactory (core.js:11397) at injectableDefOrInjectorDefFactory (core.js:11387) at providerToFactory (core.js:11451) at providerToRecord (core.js:11417) [...]

Does someone have an idea about this problem?

psoares-resilient commented 4 years ago

Hey, apparently some injection decorator was missed somewhere here... Probably a missing providedIn ... Whilst they fix It, and if it helps, you can extend the class as is and decorate it yourself. Everything worked fine after that:

@Injectable({ providedIn: 'root' })
export class InjectableTranslateMessageFormatCompiler extends TranslateMessageFormatCompiler {}

and then use it in the options that are passed in the .forRoot. i.e.:

const translateModuleConfig = {
  loader: {
    provide: TranslateLoader,
    useFactory: HttpLoaderFactory,
    deps: [HttpClient],
  },
  compiler: {
    provide: TranslateCompiler,
    useClass: InjectableTranslateMessageFormatCompiler,
  },
  isolate: false,
};
marcobuschini commented 4 years ago

@psoares-resilient why don't you fork the repository, make the change, and open a pull request? This will help them, I think.

psoares-resilient commented 4 years ago

@psoares-resilient why don't you fork the repository, make the change, and open a pull request? This will help them, I think.

Hi, I might just do that! I need a couple hours to tidy up what I'm currently working on and if everything is hunky dori, I'll create a PR

7jpsan commented 4 years ago

PR is open in https://github.com/lephyrus/ngx-translate-messageformat-compiler/pull/55

Make sure to upvote so it might get merged quickly :)

@Sijoma @marcobuschini

p.s.: @psoares-resilient is just my work github account...

lephyrus commented 4 years ago

Fixed in v4.6.0.