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
I18n localize - compile-time #32105
Conversation
2f23beb
to
9aa8438
Compare
673baa2
to
c1c1177
Compare
Note: all the commits up to |
6cdc0e5
to
b3df960
Compare
d1b9f88
to
4a81f7f
Compare
4a81f7f
to
1daf473
Compare
…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.
1daf473
to
8093b11
Compare
Closing in favour of #32881 |
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. |
Blocked on #32594
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information