Repository navigation
feat(i18n): initial $localize functionality - #31609
petebacondarwin wants to merge 8 commits into
Conversation
fa4213d to
84eff89
Compare
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only "I consent." in this pull request. Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
dcc05e6 to
78021d4
Compare
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only "I consent." in this pull request. Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
0afe5b9 to
feec4a8
Compare
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
0b49661 to
416d8b6
Compare
e3ee66b to
31738e2
Compare
16465bc to
79fe4fc
Compare
There was a problem hiding this comment.
We should be able to not introduce these side effects, depending on the way the check is made.
89c9b11 to
eba97c4
Compare
IgorMinar
left a comment
There was a problem hiding this comment.
haven't reviewed everything, but this is what I've got so far.
There was a problem hiding this comment.
right. this shouldn't be a peer dep because you'd be forcing everyone to install it or get a warning. I think we need to settle for a unspecified dependency - this is why we want the runtime and compile time warning about missing @angular/localize.
There was a problem hiding this comment.
This isn't a polyfill even when made global function, polyfills.ts is not the place to import arbitrary global libraries.
Zone.js can be considered a polyfill only because it has a stage-0 proposal.
Should user add jquery here if they want to access $ everywhere?
There was a problem hiding this comment.
I agree it is not a polyfill.
The only requirement is that @angular/localize is imported before any use of the $localize tag.
So it would be perfectly reasonable to add this just before any import of @angular/core - but only if you will only use $localize in Angular templates or Angular application code. Therefore this could be added in main.ts instead.
But... @mhevery argued that since $localize is expected to be a general purpose i18n utility, it could be used in code before Angular is loaded, in which case putting it in polyfills.ts is safer, since $localzie is then guaranteed to be there before any of the application code runs.
One example of this is when using runtime inlining of the messages and loading the translations in a script that is executed in the browser before the main.ts.
A more semantically accurate approach would be to change the build pipeline to load a new file between polyfills.ts and main.ts, (e.g. localize.ts) which is responsible for importing @angular/localize and setting up translations. But we felt that this would be too large a change to accommodate for v9.
The files in the pattern do not exist.
This commit changes the Angular compiler (ivy-only) to generate `$localize` tagged strings for component templates that use `i18n` attributes. BREAKING CHANGE Since `$localize` is a global function, it must be included in any applications that use i18n. This is achieved by importing the `@angular/localize` package into an appropriate bundle, where it will be executed before the renderer needs to call `$localize`. For CLI based projects, this is best done in the `polyfills.ts` file. ```ts import '@angular/localize'; ``` For non-CLI applications this could be added as a script to the index.html file or another suitable script file.
This has been replaced by the `$localize` tag.
This has been replaced by the `loadTranslations()` function in `@angular/localize/run_time`.
This test uses localization in the `AppComponent` component: * an `i18n` attribute in the template * a call to the `$localize` tag in the component constructor
|
GLOBAL APPROVAL: misko |
|
This needs to be reverted as it breaks g3. |
|
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 #31943TODOs
For this PR:
$localize@angular/localizeetc (perhaps via a migration?)@angular/localizeetc (perhaps via a migration?)For next PR?