Skip to content

feat(core): add support for i18n hydration #54823

Closed
devknoll wants to merge 3 commits intoangular:mainfrom
devknoll:x-i18n-serialization
Closed

feat(core): add support for i18n hydration #54823
devknoll wants to merge 3 commits intoangular:mainfrom
devknoll:x-i18n-serialization

Conversation

@devknoll
Copy link
Contributor

Add support for hydrating i18n blocks. This is accomplished by serializing information about selected ICU cases for a block during server-side rendering.

During hydration, this data is read and is used to traverse both an AST of the translated message and the DOM, in parallel, to map each LView with an RNode.

Finally, this mapping is used while nodes are being created (either via i18n or their respective instructions) to locate existing nodes.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Mar 11, 2024
@devknoll devknoll force-pushed the x-i18n-serialization branch 5 times, most recently from 58c610e to 6ea9d82 Compare March 12, 2024 17:17
@devknoll devknoll marked this pull request as ready for review March 12, 2024 17:40
@pullapprove pullapprove bot requested a review from AndrewKushnir March 12, 2024 17:40
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devknoll thanks for the PR, the change looks very good 👍 I did a first review pass and left some comments. Please let me know once the feedback is addressed, I will do another pass. Thank you.

@AndrewKushnir AndrewKushnir added action: review The PR is still awaiting reviews from at least one requested reviewer area: i18n Issues related to localization and internationalization target: minor This PR is targeted for the next minor release core: hydration labels Mar 13, 2024
@ngbot ngbot bot modified the milestone: Backlog Mar 13, 2024
@pschuler21
Copy link

Very much looking forward to this being merged

OPcxBQchmR2EYK7abQ-ezgif com-optimize

@devknoll devknoll force-pushed the x-i18n-serialization branch from 6ea9d82 to 39b02b0 Compare March 13, 2024 20:16
@devknoll devknoll force-pushed the x-i18n-serialization branch from 39b02b0 to 239770e Compare March 13, 2024 20:46
@devknoll

This comment was marked as resolved.

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devknoll thanks for addressing the feedback! 👍

I've left a few more comments and will do another pass on the main algorithm tomorrow.

@devknoll devknoll force-pushed the x-i18n-serialization branch 2 times, most recently from f55abef to d899bd9 Compare March 14, 2024 14:07
@devknoll

This comment was marked as resolved.

@devknoll devknoll force-pushed the x-i18n-serialization branch from d899bd9 to 52c519e Compare March 14, 2024 15:01
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devknoll Thanks for the update, I did another pass over the main logic and proposed a few changes.

@devknoll devknoll force-pushed the x-i18n-serialization branch from 52c519e to 4f7ceb7 Compare March 15, 2024 17:54
@devknoll devknoll force-pushed the x-i18n-serialization branch from 4f7ceb7 to 5bfeed8 Compare March 25, 2024 20:09
@devknoll devknoll force-pushed the x-i18n-serialization branch 2 times, most recently from df2a879 to 6ef2a88 Compare March 27, 2024 16:35
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devknoll looks great 👍

@devknoll devknoll force-pushed the x-i18n-serialization branch from 4c72103 to a2a99f9 Compare March 28, 2024 16:19
@angular-robot angular-robot bot requested a review from AndrewKushnir March 28, 2024 16:20
Add support for hydrating i18n blocks. This is accomplished by serializing information about selected ICU cases for a block during server-side rendering.

During hydration, this data is read and is used to traverse both an AST of the translated message and the DOM, in parallel, to map each LView with an RNode.

Finally, this mapping is used while nodes are being created (either via i18n or their respective instructions) to locate existing nodes.
Modifies the i18n pre-hydration logic to correctly support content projection and elements that act as view containers.
Rework the i18n cleanup behavior to more closely match that of containers. Specifically, we assume that nodes are going to be claimed unless they are part of a branching ICU block.

During hydration, we then track which ICU case was active at serialization time, and which was active during hydration. Any remaining cases that weren't used during hydration are then cleaned up.
@devknoll devknoll force-pushed the x-i18n-serialization branch from a2a99f9 to 9e3f2d1 Compare March 28, 2024 17:51
@devknoll
Copy link
Contributor Author

Presubmit

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 29, 2024
@atscott
Copy link
Contributor

atscott commented Mar 29, 2024

This PR was merged into the repository by commit a5fa279.

@atscott atscott closed this in 146306a Mar 29, 2024
atscott pushed a commit that referenced this pull request Mar 29, 2024
Modifies the i18n pre-hydration logic to correctly support content projection and elements that act as view containers.

PR Close #54823
atscott pushed a commit that referenced this pull request Mar 29, 2024
Rework the i18n cleanup behavior to more closely match that of containers. Specifically, we assume that nodes are going to be claimed unless they are part of a branching ICU block.

During hydration, we then track which ICU case was active at serialization time, and which was active during hydration. Any remaining cases that weren't used during hydration are then cleaned up.

PR Close #54823
@devknoll devknoll deleted the x-i18n-serialization branch March 29, 2024 18:36
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 29, 2024
henry-alakazhang pushed a commit to freelancer/angular that referenced this pull request Jun 19, 2024
Add support for hydrating i18n blocks. This is accomplished by serializing information about selected ICU cases for a block during server-side rendering.

During hydration, this data is read and is used to traverse both an AST of the translated message and the DOM, in parallel, to map each LView with an RNode.

Finally, this mapping is used while nodes are being created (either via i18n or their respective instructions) to locate existing nodes.

PR Close angular#54823
henry-alakazhang pushed a commit to freelancer/angular that referenced this pull request Jun 19, 2024
Modifies the i18n pre-hydration logic to correctly support content projection and elements that act as view containers.

PR Close angular#54823
henry-alakazhang pushed a commit to freelancer/angular that referenced this pull request Jun 19, 2024
…lar#54823)

Rework the i18n cleanup behavior to more closely match that of containers. Specifically, we assume that nodes are going to be claimed unless they are part of a branching ICU block.

During hydration, we then track which ICU case was active at serialization time, and which was active during hydration. Any remaining cases that weren't used during hydration are then cleaned up.

PR Close angular#54823
henry-alakazhang pushed a commit to freelancer/angular that referenced this pull request Aug 30, 2024
Add support for hydrating i18n blocks. This is accomplished by serializing information about selected ICU cases for a block during server-side rendering.

During hydration, this data is read and is used to traverse both an AST of the translated message and the DOM, in parallel, to map each LView with an RNode.

Finally, this mapping is used while nodes are being created (either via i18n or their respective instructions) to locate existing nodes.

PR Close angular#54823
henry-alakazhang pushed a commit to freelancer/angular that referenced this pull request Aug 30, 2024
Modifies the i18n pre-hydration logic to correctly support content projection and elements that act as view containers.

PR Close angular#54823
henry-alakazhang pushed a commit to freelancer/angular that referenced this pull request Aug 30, 2024
…lar#54823)

Rework the i18n cleanup behavior to more closely match that of containers. Specifically, we assume that nodes are going to be claimed unless they are part of a branching ICU block.

During hydration, we then track which ICU case was active at serialization time, and which was active during hydration. Any remaining cases that weren't used during hydration are then cleaned up.

PR Close angular#54823
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: i18n Issues related to localization and internationalization core: hydration detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants