Skip to content

fix(i18n): handle legacy message ids in ICUs - #33318

Closed
petebacondarwin wants to merge 7 commits into
angular:masterfrom
petebacondarwin:icu-message-ids
Closed

petebacondarwin wants to merge 7 commits into
angular:masterfrom
petebacondarwin:icu-message-ids

Conversation

@petebacondarwin

Copy link
Copy Markdown
Contributor

All but the last commit are just refactorings that made it easier for me to understand what is going on. The bug fix is in the last commit.

See FW-1637

@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer area: i18n Issues related to localization and internationalization target: major This PR is targeted for the next major release hotlist: release-blocker area: compiler Issues related to `ngc`, Angular's template compiler labels Oct 22, 2019
@petebacondarwin
petebacondarwin requested review from a team October 22, 2019 11:50
@ngbot ngbot Bot modified the milestone: needsTriage Oct 22, 2019
This commit cleans up the I18MetaVisitor code by moving all the
state of the visitor into a `context` object that gets passed along
as the nodes are being visited. This is in keeping with how visitors
are designed but also makes it easy to remove the
[definite assignment assertions](https://mariusschulz.com/blog/strict-property-initialization-in-typescript#solution-4-definite-assignment-assertion)
from the class properties.

Also, a `I18nMessageFactory` named type is exported to make it
clearer to consumers of the `createI18nMessageFactory()` function.
Previously the parameter was `id` which is ambigous because it
could be a computed value rather than a developer specified custom
value.
This better reflects what this type represents and what it is used for.
The code will now fail if the `i18n` property is of the wrong type.
This abstract class will be useful for identifying nodes that
can hold i18n data.
When computing i18n messages for templates there are two passes.
This is because messages must be computed before any whitespace
is removed. Then on a second pass, the messages must be recreated
but reusing the message ids from the first pass.

Previously ICUs were losing their legacy ids that had been computed
via the first pass. This commit fixes that by keeping track of the
message from the first pass (`previousMessage`) for ICU placeholder
nodes.

// FW-1637

@AndrewKushnir AndrewKushnir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for additional refactoring @petebacondarwin 👍
One comment (we can fix in the next PRs) - we now have 2 I18nMeta types: one represents i18n message (including AST), the second one represents metadata collected from i18n attributes. We probably need to find different names to disambiguate that in the code.

@AndrewKushnir AndrewKushnir added action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 22, 2019
@AndrewKushnir

Copy link
Copy Markdown
Contributor

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker and removed action: presubmit The PR is in need of a google3 presubmit labels Oct 22, 2019
@matsko matsko closed this in df92abc Oct 22, 2019
matsko pushed a commit that referenced this pull request Oct 22, 2019
…#33318)

Previously the parameter was `id` which is ambigous because it
could be a computed value rather than a developer specified custom
value.

PR Close #33318
matsko pushed a commit that referenced this pull request Oct 22, 2019
This better reflects what this type represents and what it is used for.

PR Close #33318
matsko pushed a commit that referenced this pull request Oct 22, 2019
The code will now fail if the `i18n` property is of the wrong type.

PR Close #33318
matsko pushed a commit that referenced this pull request Oct 22, 2019
…33318)

This abstract class will be useful for identifying nodes that
can hold i18n data.

PR Close #33318
matsko pushed a commit that referenced this pull request Oct 22, 2019
When computing i18n messages for templates there are two passes.
This is because messages must be computed before any whitespace
is removed. Then on a second pass, the messages must be recreated
but reusing the message ids from the first pass.

Previously ICUs were losing their legacy ids that had been computed
via the first pass. This commit fixes that by keeping track of the
message from the first pass (`previousMessage`) for ICU placeholder
nodes.

// FW-1637

PR Close #33318
@petebacondarwin
petebacondarwin deleted the icu-message-ids branch October 22, 2019 21:14
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 Nov 22, 2019
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 area: i18n Issues related to localization and internationalization cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants