transloco icon indicating copy to clipboard operation
transloco copied to clipboard

feat(transloco): add intlmessageformat transpiler

Open f-aubert opened this issue 1 year ago • 7 comments

Adding an alternative messageformat transpiler based on formatjs/intlmessageformat

white_check_mark Closes: #364

PR Checklist

Please check if your PR fulfills the following requirements:

  • [X] The commit message follows our guidelines: https://github.com/ngneat/transloco/blob/master/CONTRIBUTING.md#commit
  • [X] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Transloco MessageFormatTranspiler may lead to CSP Problems due to usage (in messageformat.js) of the eval function.

Issue Number: #364

What is the new behavior?

Provide an alternative IntlMessaeFormatTranspiler based on formatjs/intl(messageformat)

Does this PR introduce a breaking change?

[ ] Yes
[X] No

Other information

I'd gladly discuss it with you as I'm not an expert in packaging libs! I also inspired myself a lot from your MessageFormatTranspiler. Thanks.

f-aubert avatar Apr 25 '23 11:04 f-aubert

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

stackblitz[bot] avatar Apr 25 '23 11:04 stackblitz[bot]

  1. Please note I used version 2.3.4 of formatjs/intl as more recent version needs at least typescript 4.7. As soon as you update typescript, we can take the latest formatjs/int 2.7.1 at the time of writing.

  2. Caching is not yet functional. But I'd like to shortly discuss it before fixing/implementing. Does it make still sense? What should we cache? The AST (decomposition) of the message in ICU Format? The final translated/transpiled message?

f-aubert avatar Apr 25 '23 11:04 f-aubert

@f-aubert Thanks for the PR! There is a PR for upgrading the internal to the latest versions, let's continue this after it's merged since we want TS v4.7. Regarding the cache, I'll review it when I have the time and leave comments. (might take a while so be patient 🙂 )

shaharkazaz avatar Apr 25 '23 17:04 shaharkazaz

@shaharkazaz the other PR was merged, do we want to go on with this one?

f-aubert avatar Jul 11 '23 13:07 f-aubert

hello @f-aubert @shaharkazaz do we have any update on this? I also cannot ship with unsafe-eval and I use MessageFormat.

pedroqueiroga avatar Oct 02 '23 19:10 pedroqueiroga

@shaharkazaz any update on this one? I'd gladly help some more

f-aubert avatar Feb 03 '24 23:02 f-aubert

@f-aubert Hi! sorry for not being here for a while, a lot going on both personally and nationally. A lot of changes were made to this repo ever since this PR was open, if you'd like to update your branch with all the changes I'll do my best to push this forward 🔥

shaharkazaz avatar May 14 '24 15:05 shaharkazaz