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

bug(ivy): i18n problem with select ICU expressions #34018

Closed
osnoser1 opened this issue Nov 24, 2019 · 5 comments
Closed

bug(ivy): i18n problem with select ICU expressions #34018

osnoser1 opened this issue Nov 24, 2019 · 5 comments
Assignees
Labels
area: i18n regression Indicates than the issue relates to something that worked in a previous version state: has PR

Comments

@osnoser1
Copy link

osnoser1 commented Nov 24, 2019

🐞 bug report

Affected Package

The issue is caused by package @angular/....

Is this a regression?

Yes, works with VE.

Description

When using a select icu expression throws an exception at runtime.

🔬 Minimal Reproduction

Use select ICU expressions in angular apps.
Minimal repo: https://github.com/osnoser1/angular9-i18n-ivy-ssr

  • Install dependencies.
  • Execute ng serve -c es

🔥 Exception or Error


core.js:17 ERROR Error: ASSERTION ERROR: Missing key "other" in ICU statement.
    at throwError (core.js:17)
    at assertGreaterThan (core.js:17)
    at parseICUBlock (vendor.js:49378)
    at extractParts (vendor.js:49276)
    at i18nStartFirstPass (vendor.js:49726)
    at ɵɵi18nStart (vendor.js:49618)
    at Module.ɵɵi18n (vendor.js:50631)
    at AppComponent_Template (app.component.html:305)
    at executeTemplate (core.js:17)
    at renderView (core.js:17)

🌍 Your Environment

Angular Version:


9.0.0-rc.3

Anything else relevant?

@osnoser1 osnoser1 changed the title i18n problem with select ICU expressions bug(ivy): i18n problem with select ICU expressions Nov 24, 2019
@AndrewKushnir AndrewKushnir self-assigned this Nov 24, 2019
@ngbot ngbot bot added this to the needsTriage milestone Nov 24, 2019
@AndrewKushnir
Copy link
Contributor

Hi @osnoser1, thanks for reporting the issue.

The problem appeared because an ICU defined in the app.component.html template has no "other" case, i.e.:

{test, select, male {male} female {female}}

There is a check that verifies "other" case presence and throws the error. That check was implemented to better align with ICU format spec, which states that the "other" case is required:

The keyword "other" must occur in the pattern string, or the error U_DEFAULT_KEYWORD_MISSING is returned.

However since "other" cases were not required in View Engine, we decided to change this condition in Ivy as well to better align with existing behavior and I've created a PR to remove the mentioned check. Meanwhile you can update ICUs to add "other" cases (with empty content) to avoid the problem until the mentioned PR lands. Here is an example of the original ICU with the "other" case:

{test, select, male {male} female {female} other {}}

Thank you.

@osnoser1
Copy link
Author

Thanks @AndrewKushnir for the detailed explanation and for workaround while merging the PR. Really grateful.

@AndrewKushnir
Copy link
Contributor

@osnoser1, just want to let you know that the fix from the mentioned PR was included into v9.0.0-rc.4, which was released a few hours ago and is now available on NPM. I'll close this ticket, but feel free to reopen it if the problem still exists. Thank you.

@osnoser1
Copy link
Author

Thank you very much @AndrewKushnir 😄

@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 Dec 29, 2019
@kara kara added regression Indicates than the issue relates to something that worked in a previous version and removed severity5: ivy-compat labels Feb 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: i18n regression Indicates than the issue relates to something that worked in a previous version state: has PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants