Reputation: 1513
I am using ngx-translate-messageformat-compiler in Angular, but according to their documentation, they require 'unsafe-eval' for the script-src.
Is there any alternative that anyone knows about?
I researched: https://formatjs.io/docs/intl-messageformat/
But it doesn't seem to have any API reference for Angular. Anyone knows any better solution?
Upvotes: 3
Views: 1482
Reputation: 3390
I just ran into the same problem and used FormatJs to use it in a TranslateCompiler. It supports Angular 13 and 14. If you are using an earlier Angular version, you can just copy this file into your code translate-format-js-compiler.ts and it should work.
Otherwise, this is the npm dependency: ngx-translate-formatjs-compiler
Upvotes: 1
Reputation: 11
We had the same issue with building the project with webpack, maybe you can try to use ngx-translate-parser-plural-select
Instead of using a compiler like this...
compiler: {
provide: TranslateCompiler,
useClass: TranslateMessageFormatCompiler
}
...you have to define parser, like this:
parser: {
provide: TranslateParser,
useClass: TranslateICUParser
}
Everything else should be untouched.
Upvotes: 0