Skip to content

Integrate blocks into the i18n pipeline#52958

Closed
crisbeto wants to merge 2 commits intoangular:mainfrom
crisbeto:control-flow-i18n
Closed

Integrate blocks into the i18n pipeline#52958
crisbeto wants to merge 2 commits intoangular:mainfrom
crisbeto:control-flow-i18n

Conversation

@crisbeto
Copy link
Member

@crisbeto crisbeto commented Nov 16, 2023

When blocks were first implemented, they were treated as containers for i18n purposes which meant that while their content was processed, the container would be basically transparent. This comes with a couple of problems:

  1. We generate template instructions for the blocks which ends up causing an error at runtime in some situations (e.g. block nested in a translated element.
  2. Blocks aren't shown in the extracted message string which can cause it to misrepresent the meaning since blocks can change the structure of the message.

These changes address the issue by fully integrating blocks into the i18n pipeline. Blocks are represented as a new node called BlockPlaceholder in the i18n AST, with the one exception being @switch which is still a Container while the separate cases are treated as BlockPlaceholder.

Includes the following commits:

fix(compiler): produce placeholder for blocks in i18n bundles

When blocks were initially implemented, they were represented as containers in the i18n AST. This is problematic, because block affect the structure of the message.

These changes introduce a new BlockPlaceholder AST node and integrate it into the i18n pipeline. With the new node blocks are represented with the START_BLOCK_<name> and CLOSE_BLOCK_<name> placeholders.

fix(compiler): generate i18n instructions for blocks

Adds support for generating i18n instructions inside of blocks.

Fixes #52540.
Fixes #52767.

@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release area: compiler Issues related to `ngc`, Angular's template compiler labels Nov 16, 2023
@ngbot ngbot bot added this to the Backlog milestone Nov 16, 2023
@crisbeto crisbeto marked this pull request as ready for review November 16, 2023 14:03
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.

@crisbeto awesome work 👍

@AndrewKushnir AndrewKushnir removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Nov 16, 2023
When blocks were initially implemented, they were represented as containers in the i18n AST. This is problematic, because block affect the structure of the message.

These changes introduce a new `BlockPlaceholder` AST node and integrate it into the i18n pipeline. With the new node blocks are represented with the `START_BLOCK_<name>` and `CLOSE_BLOCK_<name>` placeholders.
Adds support for generating i18n instructions inside of blocks.

Fixes angular#52540.
Fixes angular#52767.
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Nov 17, 2023
@AndrewKushnir
Copy link
Contributor

Caretaker note: this PR will be merged on Monday (11/20).

@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 406049b.

AndrewKushnir pushed a commit that referenced this pull request Nov 20, 2023
Adds support for generating i18n instructions inside of blocks.

Fixes #52540.
Fixes #52767.

PR Close #52958
AndrewKushnir pushed a commit that referenced this pull request Nov 20, 2023
When blocks were initially implemented, they were represented as containers in the i18n AST. This is problematic, because block affect the structure of the message.

These changes introduce a new `BlockPlaceholder` AST node and integrate it into the i18n pipeline. With the new node blocks are represented with the `START_BLOCK_<name>` and `CLOSE_BLOCK_<name>` placeholders.

PR Close #52958
AndrewKushnir pushed a commit that referenced this pull request Nov 20, 2023
Adds support for generating i18n instructions inside of blocks.

Fixes #52540.
Fixes #52767.

PR Close #52958
@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 Dec 21, 2023
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this pull request Jan 23, 2024
…r#52958)

When blocks were initially implemented, they were represented as containers in the i18n AST. This is problematic, because block affect the structure of the message.

These changes introduce a new `BlockPlaceholder` AST node and integrate it into the i18n pipeline. With the new node blocks are represented with the `START_BLOCK_<name>` and `CLOSE_BLOCK_<name>` placeholders.

PR Close angular#52958
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this pull request Jan 23, 2024
Adds support for generating i18n instructions inside of blocks.

Fixes angular#52540.
Fixes angular#52767.

PR Close angular#52958
rlmestre pushed a commit to rlmestre/angular that referenced this pull request Jan 26, 2024
…r#52958)

When blocks were initially implemented, they were represented as containers in the i18n AST. This is problematic, because block affect the structure of the message.

These changes introduce a new `BlockPlaceholder` AST node and integrate it into the i18n pipeline. With the new node blocks are represented with the `START_BLOCK_<name>` and `CLOSE_BLOCK_<name>` placeholders.

PR Close angular#52958
rlmestre pushed a commit to rlmestre/angular that referenced this pull request Jan 26, 2024
Adds support for generating i18n instructions inside of blocks.

Fixes angular#52540.
Fixes angular#52767.

PR Close angular#52958
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…r#52958)

When blocks were initially implemented, they were represented as containers in the i18n AST. This is problematic, because block affect the structure of the message.

These changes introduce a new `BlockPlaceholder` AST node and integrate it into the i18n pipeline. With the new node blocks are represented with the `START_BLOCK_<name>` and `CLOSE_BLOCK_<name>` placeholders.

PR Close angular#52958
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
Adds support for generating i18n instructions inside of blocks.

Fixes angular#52540.
Fixes angular#52767.

PR Close angular#52958
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: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

2 participants

Comments