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

feat(i18n): initial `$localize` functionality #31609

Closed

Conversation

@petebacondarwin
Copy link
Member

commented Jul 17, 2019

Blocked on #31943

TODOs

For this PR:

  • fix AOT tests to provide a runtime implementation of $localize
  • fix material legacy tests to update with @angular/localize etc (perhaps via a migration?)
  • fix integration tests to update with @angular/localize etc (perhaps via a migration?)

For next PR?

  • write the update migration schematic
  • write the new project schematic
  • write compile-time inliner (Babel plugin/standalone tool)

@googlebot googlebot added the cla: yes label Jul 17, 2019

@petebacondarwin petebacondarwin force-pushed the petebacondarwin:i18n-localize-init branch 2 times, most recently from fa4213d to 84eff89 Jul 17, 2019

tsconfig.json Outdated Show resolved Hide resolved
packages/i18n/localize/src/hash.ts Outdated Show resolved Hide resolved
packages/i18n/localize/src/hash.ts Outdated Show resolved Hide resolved
@googlebot

This comment has been minimized.

Copy link

commented Jul 17, 2019

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 cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no and removed cla: yes labels Jul 17, 2019

@matsko matsko added the comp: i18n label Jul 17, 2019

@ngbot ngbot bot added this to the needsTriage milestone Jul 17, 2019

@ocombe
ocombe approved these changes Jul 18, 2019

@petebacondarwin petebacondarwin force-pushed the petebacondarwin:i18n-localize-init branch from dcc05e6 to 78021d4 Jul 18, 2019

@googlebot

This comment has been minimized.

Copy link

commented Jul 18, 2019

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot removed the cla: no label Jul 18, 2019

@googlebot

This comment has been minimized.

Copy link

commented Jul 18, 2019

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 cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no and removed cla: yes labels Jul 18, 2019

@petebacondarwin petebacondarwin force-pushed the petebacondarwin:i18n-localize-init branch from 0afe5b9 to feec4a8 Jul 18, 2019

@googlebot

This comment has been minimized.

Copy link

commented Jul 18, 2019

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Jul 18, 2019

@petebacondarwin petebacondarwin marked this pull request as ready for review Jul 18, 2019

@petebacondarwin petebacondarwin requested review from IgorMinar and angular/fw-dev-infra as code owners Jul 18, 2019

@petebacondarwin petebacondarwin force-pushed the petebacondarwin:i18n-localize-init branch 2 times, most recently from 0b49661 to 416d8b6 Jul 18, 2019

@petebacondarwin petebacondarwin force-pushed the petebacondarwin:i18n-localize-init branch 2 times, most recently from 170920c to be63d9c Aug 30, 2019

refactor(ivy): update the compiler to emit `$localize` tags
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.
refactor(ivy): remove `i18nLocalize` instruction
This has been replaced by the `$localize` tag.
refactor(ivy): remove `i18nConfigureLocalize` instruction
This has been replaced by the `loadTranslations()` function in
`@angular/localize/run_time`.
test(ivy): add cli-hello-world-ivy-i18n integration test
This test uses localization in the `AppComponent` component:

* an `i18n` attribute in the template
* a call to the `$localize` tag in the component constructor

@petebacondarwin petebacondarwin force-pushed the petebacondarwin:i18n-localize-init branch from be63d9c to 3b9909f Aug 30, 2019

@mhevery

This comment has been minimized.

Copy link
Member

commented Aug 30, 2019

GLOBAL APPROVAL: misko

@mhevery mhevery closed this in b34bdf5 Aug 30, 2019

mhevery added a commit that referenced this pull request Aug 30, 2019
mhevery added a commit that referenced this pull request Aug 30, 2019
refactor(ivy): update the compiler to emit `$localize` tags (#31609)
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.

PR Close #31609
mhevery added a commit that referenced this pull request Aug 30, 2019
refactor(ivy): remove `i18nLocalize` instruction (#31609)
This has been replaced by the `$localize` tag.

PR Close #31609
mhevery added a commit that referenced this pull request Aug 30, 2019
refactor(ivy): remove `i18nConfigureLocalize` instruction (#31609)
This has been replaced by the `loadTranslations()` function in
`@angular/localize/run_time`.

PR Close #31609
mhevery added a commit that referenced this pull request Aug 30, 2019
mhevery added a commit that referenced this pull request Aug 30, 2019
test(ivy): add cli-hello-world-ivy-i18n integration test (#31609)
This test uses localization in the `AppComponent` component:

* an `i18n` attribute in the template
* a call to the `$localize` tag in the component constructor

PR Close #31609
mhevery added a commit that referenced this pull request Aug 30, 2019

@petebacondarwin petebacondarwin deleted the petebacondarwin:i18n-localize-init branch Aug 30, 2019

@mhevery

This comment has been minimized.

Copy link
Member

commented Sep 3, 2019

This needs to be reverted as it breaks g3.

/checkbox_logo.closure.js:47: ERROR - [JSC_UNDEFINED_VARIABLE] variable $localize is undeclared
    I18N_6 = $localize `User portrait`;
             ^^^^^^^^^
sabeersulaiman added a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
sabeersulaiman added a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
sabeersulaiman added a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
refactor(ivy): update the compiler to emit `$localize` tags (angular#…
…31609)

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.

PR Close angular#31609
sabeersulaiman added a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
refactor(ivy): remove `i18nLocalize` instruction (angular#31609)
This has been replaced by the `$localize` tag.

PR Close angular#31609
sabeersulaiman added a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
refactor(ivy): remove `i18nConfigureLocalize` instruction (angular#31609
)

This has been replaced by the `loadTranslations()` function in
`@angular/localize/run_time`.

PR Close angular#31609
sabeersulaiman added a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
sabeersulaiman added a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
test(ivy): add cli-hello-world-ivy-i18n integration test (angular#31609)
This test uses localization in the `AppComponent` component:

* an `i18n` attribute in the template
* a call to the `$localize` tag in the component constructor

PR Close angular#31609
sabeersulaiman added a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.