Skip to content

feat(ivy): support i18n without closure - #28689

Closed
ocombe wants to merge 1 commit into
angular:masterfrom
ocombe:feat/ivy/runtime-i18n-shim
Closed

ocombe wants to merge 1 commit into
angular:masterfrom
ocombe:feat/ivy/runtime-i18n-shim

Conversation

@ocombe

@ocombe ocombe commented Feb 13, 2019 •

Copy link
Copy Markdown
Contributor

So far using runtime i18n with ivy meant that you needed to use Closure and goog.getMsg (or a polyfill). This PR changes the compiler to only output closure code when the compiler option i18nUseClosure is set to true. This option is set to false by the compiler-cli when the option i18nInFile is used, which is what happens when you load a translations file.
This means that if you use the Angular CLI with ivy and load a translations file, you can use i18n and the application will not throw at runtime.
For now it will not translate your application, but at least you can try ivy without having to remove all of your i18n code and configuration.

@ocombe
ocombe requested a review from IgorMinar as a code owner February 13, 2019 13:52
@ocombe
ocombe requested review from a team February 13, 2019 13:52

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for ngcc

@ocombe
ocombe force-pushed the feat/ivy/runtime-i18n-shim branch from 7742649 to 5019827 Compare February 13, 2019 14:07
@ocombe ocombe added target: major This PR is targeted for the next major release area: i18n Issues related to localization and internationalization comp: ivy labels Feb 13, 2019
@ngbot ngbot Bot added this to the needsTriage milestone Feb 13, 2019
@mhevery mhevery self-assigned this Feb 13, 2019

@AndrewKushnir AndrewKushnir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ocombe looks good! Just left a couple minor comments. Thank you.

Comment thread packages/core/src/render3/i18n.ts Resolved
@ocombe

ocombe commented Feb 18, 2019

Copy link
Copy Markdown
Contributor Author

Blocked by https://angular-team.atlassian.net/browse/FW-1076 (bazel issue)

@ocombe
ocombe force-pushed the feat/ivy/runtime-i18n-shim branch from e2c6635 to 8ef7ee5 Compare February 20, 2019 09:26
@gregmagolan

Copy link
Copy Markdown
Contributor

Blocked by https://angular-team.atlassian.net/browse/FW-1076 (bazel issue)

Alex got #21883 merged which should resolve FW-1076. You should be unblocked on master.

@ocombe
ocombe force-pushed the feat/ivy/runtime-i18n-shim branch from 8ef7ee5 to a578389 Compare February 26, 2019 12:57
@ocombe

ocombe commented Feb 26, 2019 •

Copy link
Copy Markdown
Contributor Author

@gregmagolan just rebased on master and it doesn't change anything for me. It still doesn't take the tsconfig into consideration. Am I supposed to change something else to the bazel build file to make this work?
edit: it works now, thanks

@ocombe
ocombe force-pushed the feat/ivy/runtime-i18n-shim branch 2 times, most recently from f4f2e48 to aebd03a Compare February 27, 2019 21:01
@ocombe ocombe added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP state: blocked labels Feb 27, 2019
@ocombe
ocombe force-pushed the feat/ivy/runtime-i18n-shim branch 4 times, most recently from 7618e6a to 3afbb98 Compare April 5, 2019 16:20
@ocombe ocombe added the action: merge The PR is ready for merge by the caretaker label Apr 5, 2019

@IgorMinar IgorMinar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please address the comments I posted and split this PR into two - one for cli update to beta.11 and one for the remaining changes. that way we can isolate the payload size regression and attribute it to this change or an issue in cli. thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please not change this. if you need a newer version, then you should update the root package.json and not this one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we talked about this at the framework meeting yesterday and it was decided to only change this in the ivy integration apps for now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please share why?

my concern is that we are making our integration testing infrastructure more fragile if we make this change and we are increasing technical debt. I'd prefer not to make a change like that unless we really really have to (and then there should be a follow up work to remove this temporary hack which should be tracked and scheduled so that we don't forget).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why will this happen? if this really is a TODO then we should likely have an item in jira for this. If this is just a note then make it a note and not a TODO

@ocombe ocombe Apr 5, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because ɵi18nConfigureLocalize is just temporary (as explained in its api docs) until we can work on the service. We needed something for our tests to make i18n work without closure so that people can test ivy even if they use i18n.
There is a already jira ticket for the runtime service (not specifically this todo, but it's part of it).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me try to explain my question better: if I'm reading this todo in the codebase a month from now, what should I do, how should I interpret it, or how can I learn more about what this comment stands for?

In its current form, all I can do is ask you personally what this is about and where I can learn more, and that doesn't scale.

@ocombe ocombe Apr 9, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the todo, let me know if it is still unclear.

Comment thread integration/_payload-limits.json Resolved
@ocombe

ocombe commented Apr 5, 2019

Copy link
Copy Markdown
Contributor Author

@IgorMinar the size regression was present before the cli change. I tried to update the cli version to see if my change to tree shake ngI18nClosureMode could fix the regression (angular/angular-cli#13905) but it didn't change anything (in fact it added 2 bytes).

@ocombe ocombe removed the action: merge The PR is ready for merge by the caretaker label Apr 8, 2019
@ocombe
ocombe force-pushed the feat/ivy/runtime-i18n-shim branch 2 times, most recently from 32d8695 to 29445e6 Compare April 8, 2019 08:46
@ocombe ocombe added the action: merge The PR is ready for merge by the caretaker label Apr 8, 2019
@ocombe
ocombe requested a review from IgorMinar April 8, 2019 09:05
@ocombe

ocombe commented Apr 8, 2019

Copy link
Copy Markdown
Contributor Author

I removed the cli changes, and rebased onto master and it fixed the size regression issue. @IgorMinar can you approve the PR now? :)

@ocombe
ocombe requested review from IgorMinar and alxhub and removed request for IgorMinar April 8, 2019 13:29

@IgorMinar IgorMinar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm except for that one todo

@IgorMinar IgorMinar added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Apr 9, 2019
@ocombe ocombe removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Apr 9, 2019
@kara

kara commented Apr 9, 2019

Copy link
Copy Markdown
Contributor

presubmit

@ocombe
ocombe force-pushed the feat/ivy/runtime-i18n-shim branch 2 times, most recently from 129e4c7 to 092e71b Compare April 11, 2019 09:18
So far using runtime i18n with ivy meant that you needed to use Closure and `goog.getMsg` (or a polyfill). This PR changes the compiler to output both closure & non-closure code, while the unused option will be tree-shaken by minifiers.
This means that if you use the Angular CLI with ivy and load a translations file, you can use i18n and the application will not throw at runtime.
For now it will not translate your application, but at least you can try ivy without having to remove all of your i18n code and configuration.
@IgorMinar

Copy link
Copy Markdown
Contributor

previews presubmit failed, so here is a new one after the last set of changes: http://test/OCL:243069482:BASE:243069609:1554994952547:fae7a7a0

@angular-automatic-lock-bot

Copy link
Copy Markdown

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: i18n Issues related to localization and internationalization cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants