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

I18n localize - compile-time #32105

Closed

Conversation

petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Aug 12, 2019

Blocked on #32594

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

@ngbot ngbot bot added this to the needsTriage milestone Aug 14, 2019
@petebacondarwin petebacondarwin force-pushed the i18n-localize-babel branch 12 times, most recently from 673baa2 to c1c1177 Compare August 29, 2019 21:19
@ocombe
Copy link
Contributor

ocombe commented Aug 30, 2019

Note: all the commits up to test: make cli-hello-world-ivy-minimal/debug-test.sh executable are part of the other unmerged PR: #31609 and should not be reviewed here

@petebacondarwin petebacondarwin changed the title I18n localize babel I18n localize - compile-time Aug 30, 2019
@petebacondarwin petebacondarwin force-pushed the i18n-localize-babel branch 8 times, most recently from 6cdc0e5 to b3df960 Compare September 3, 2019 16:08
…placeholder

Previously if a translation contains a placeholder that
does not exist in the message being translated, that
placeholder is evaluated as `undefined`.

Translations should never contain such placeholder names
so now `translate` will throw a helpful error in instead.
The missing translation and invalid placeholder warnings now contain the
"meaning" if one was provided.
Previously the metadata and placeholder blocks were serialized in
a variety of places. Moreover the code for creating the `LocalizedString`
AST node was doing serialization, which break the separation of concerns.

Now this is all done by the code that renders the AST and is refactored into
helper functions to avoid repeating the behaviour.
Metadata blocks are delimited by colons. Previously the code naively just
looked for the next colon in the string as the end marker.

This commit supports escaping colons within the metadata content.
The Angular compiler has been updated to add escaping as required.
In an attempt to be compatible with previous translation files
the Angular compiler was generating instructions that always
included the message id. This was because it was not possible
to accurately re-generate the id from the calls to `$localize()` alone.

In line with https://hackmd.io/EQF4_-atSXK4XWg8eAha2g this
commit changes the compiler so that it only renders ids if they are
"custom" ones provided by the template author.

BREAKING CHANGE:

When translating messages generated by the Angular compiler
from i18n tags in templates, the `$localize.translate()` function
will compute message ids, if no custom id is provided, using a
common digest function that only relies upon the information
available in the `$localize()` calls.

This computed message id will not be the same as the message
ids stored in legacy translation files. Such files will need to be
migrated to use the new common digest function.

This only affects developers who have been trialling `$localize`, have
been calling `loadTranslations()`, and are not exclusively using custom
ids in their templates.
This commit provides the main pieces for inlining translations at compile-time.
@petebacondarwin
Copy link
Member Author

Closing in favour of #32881

@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 Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants