Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transloco): add intlmessageformat transpiler #649

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

f-aubert
Copy link

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:

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.

Adding an alternative messageformat transpiler based on formatjs/intlmessageformat

white_check_mark Closes: jsverse#364

Signed-off-by: isc-auf <[email protected]>
@stackblitz
Copy link

stackblitz bot commented Apr 25, 2023

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

@f-aubert
Copy link
Author

f-aubert commented Apr 25, 2023

  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?

@shaharkazaz
Copy link
Collaborator

shaharkazaz commented Apr 25, 2023

@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 🙂 )

@f-aubert
Copy link
Author

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

@pedroqueiroga
Copy link
Contributor

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

@f-aubert
Copy link
Author

f-aubert commented Feb 3, 2024

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

@shaharkazaz
Copy link
Collaborator

@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 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MessageFormat transpiler throws 'unsafe-eval' when activating CSP
3 participants