Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

angular-messageFormat select statement bug #11414

Closed
brycecr opened this issue Mar 24, 2015 · 3 comments
Closed

angular-messageFormat select statement bug #11414

brycecr opened this issue Mar 24, 2015 · 3 comments

Comments

@brycecr
Copy link

brycecr commented Mar 24, 2015

I have the following in my template

<span>
   <!--i18n: Gender fun-->
   {{model.gender, select,
         male   {He gave me a cactus}
         female {She gave me a cactus}
         other  {They gave me a cactus}
   }}
   <!--/i18n-->
</span>

And I am getting an error that says 'other is a required option' with stacktrace:

at http://localhost:1080/static/lib/angular/angular.min.js:6:434
    at new MessageSelectorBase (http://localhost:1080/static/lib/angular/angular-messageFormat.js:102:11)
    at MessageSelectorBase.SelectMessage (http://localhost:1080/static/lib/angular/angular-messageFormat.js:165:23)
    at MessageFormatParser.ruleSelectKeyword (http://localhost:1080/static/lib/angular/angular-messageFormat.js:577:21)
    at MessageFormatParser.run (http://localhost:1080/static/lib/angular/angular-messageFormat.js:451:12)
    at interpolate (http://localhost:1080/static/lib/angular/angular-messageFormat.js:891:14)

I tried copy-pasting the example from the docs for the messageformat pr and got the same result.

@brycecr
Copy link
Author

brycecr commented Mar 24, 2015

@chirayuk

@brycecr
Copy link
Author

brycecr commented Mar 24, 2015

I should mention also that the declarative plurals are always going to other. This seems to be a related problem, plurals just don't throw an error in this case because they default to other: it looks like the MessageFormatParser objects are somehow borked and this.choices returns {}. I am on ea9fd82.

This is what JSON.stringify(this) gives for the MessageFormatParser object at line 577

{"text":"\n   {{model.gender, select,\n         male   {He gave me a cactus}\n         female {She gave me a cactus}\n         other  {They gave me a cactus}\n   }}\n   ","index":144,"mustHaveExpression":true,"allOrNothing":false,"expressionMinusOffsetFn":null,"pluralOffset":null,"choices":{},"choiceKey":"other","interpolationParts":{"allOrNothing":false,"textParts":["They gave me a cactus"],"expressionFns":[],"expressionIndices":[],"partialText":"","concatParts":null},"msgStartIndex":122,"nestedStateStack":[{"expressionFn":null,"expressionMinusOffsetFn":null,"pluralOffset":null,"choices":null,"choiceKey":null,"interpolationParts":{"allOrNothing":false,"textParts":[],"expressionFns":[],"expressionIndices":[],"partialText":"\n   ","concatParts":null},"ruleChoiceKeyword":null,"msgStartIndex":null,"expressionStartIndex":null}],"parsedFn":null,"ruleStack":[null,null],"interpNestLevel":null,"expressionStartIndex":6,"stringStartIndex":null,"stringQuote":null,"stringInterestsRe":null,"angularOperatorStack":[],"textPart":"They gave me a cactus"}

@chirayuk
Copy link
Contributor

Yup. This is a bug. I'll be fixing it in the next day or two.

@chirayuk chirayuk self-assigned this Apr 14, 2015
chirayuk added a commit to chirayuk/angular.js that referenced this issue Apr 14, 2015
Add an E2E test that works against the minified module to test that the
minified build works correctly.

Fix a bug where mustHaveExpression was passed through to submessages
unchanged. Use of the messageFormat syntax automatically means that you
are using an expression.  Therefore, submessages should not be required
to also have messages.  This closes angular#11414
chirayuk added a commit to chirayuk/angular.js that referenced this issue Apr 14, 2015
Add an E2E test that works against the minified module to test that the
minified build works correctly.

Fix a bug where mustHaveExpression was passed through to submessages
unchanged. Use of the messageFormat syntax automatically means that you
are using an expression.  Therefore, submessages should not be required
to also have messages.  This closes angular#11414
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
Add an E2E test that works against the minified module to test that the
minified build works correctly.

Fix a bug where mustHaveExpression was passed through to submessages
unchanged. Use of the messageFormat syntax automatically means that you
are using an expression.  Therefore, submessages should not be required
to also have messages.

Closes angular#11414
Closes angular#11592
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants