-
Notifications
You must be signed in to change notification settings - Fork 26.3k
refactor(compiler): trim expression whitespace when preserveSignificantWhitespace === false
#58176
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
Conversation
This serializes the expression AST back into a string. This is useful to normalize whitespace in expressions so i18n messages are not affected by insignificant changes (such as going from `{{ foo }}` to `{{\n foo\n}}`).
… `preserveSignificantWhitespace === false`. This parses and reserializes expressions to normalize their whitespace formatting and make them more durable to insignificant changes in whitespace which might otherwise alter message IDs despite no translator-meaningful change being made.
While effective, `preservePlaceholders` unfortunately is not viable in google3 at the moment due to some complexities with how TC extracts messages. Therefore this feature is being removed in favor of whitespace trimming of expressions, which is viable for TC and provides most of the same benefit. This is a partial revert of dab722f.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks @dgp1130 👍
TGP (with flag disabled): http://test/OCL:685031311:BASE:685031062:1728703209245:53d763a5 I'll run another TGP with the flag enabled just to make sure enabling it won't cause any problems. |
TGP with the relevant flag enabled. There are some XMB golden tests which failed, but that's expected because enabling the flag changes message IDs, so there's no issue. One project had a TC extraction failure due to a couple of now-duplicate messages, but we can avoid that by just adding a Should be good to merge! |
This PR was merged into the repository by commit 6d33ab5. The changes were merged into the following branches: main |
… `preserveSignificantWhitespace === false`. (#58176) This parses and reserializes expressions to normalize their whitespace formatting and make them more durable to insignificant changes in whitespace which might otherwise alter message IDs despite no translator-meaningful change being made. PR Close #58176
While effective, `preservePlaceholders` unfortunately is not viable in google3 at the moment due to some complexities with how TC extracts messages. Therefore this feature is being removed in favor of whitespace trimming of expressions, which is viable for TC and provides most of the same benefit. This is a partial revert of dab722f. PR Close #58176
Fixes some tests that started failing, because angular#58154 made it so placeholder-only messages are extracted while angular#58176 added some tests that only contain placeholders.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR trims whitespace in expressions when
preserveSignificantWhitespace === false
. This allows messages to be a bit more durable to insignificant whitespace changes. For example, reformatting the following:Into:
Is a whitespace-only change which has no visible effect to translators. Therefore we trim whitespace before extracting messages and normalize it to a standard format (
{{name}}
).This PR also removes the functionality for ignoring placeholder expressions entirely (originally added as part of dab722f). Ideally, we wouldn't take placeholders into account at all, since whether an expression is
{{foo}}
or{{bar}}
is also irrelevant to the translator. However doing so causes some challenges with TC, so we can't go that far just yet (see http://b/367255149#comment10). Therefore this PR rolls back that particular feature and replaces it with this one which trims expression whitespace instead.