Skip to content
This repository was archived by the owner on May 23, 2019. It is now read-only.

Fixed formatting of 0 number literal#136

Closed
JackieChiles wants to merge 1 commit intoformatjs:masterfrom
JackieChiles:fix-zero-string
Closed

Fixed formatting of 0 number literal#136
JackieChiles wants to merge 1 commit intoformatjs:masterfrom
JackieChiles:fix-zero-string

Conversation

@JackieChiles
Copy link

I found this issue when using ember-intl. With the following:

Template
{{t 'numItems' num=0}}

Translation
"numItems": "There are ({num}) items"

The rendered string was There are () items whereas the expected output is There are (0) items. This PR allows intl-messageformat to correctly render the literal 0.

@yahoocla
Copy link

yahoocla commented Jun 8, 2016

Thank you for submitting this pull request, however I do not see a valid CLA on file for you. Before we can merge this request please visit https://yahoocla.herokuapp.com/ and agree to the terms. Thanks! 😄

@JackieChiles
Copy link
Author

@jasonmit This may be of interest to you.

@ericf
Copy link
Collaborator

ericf commented Jun 8, 2016

Use {num, number} instead.

@JackieChiles
Copy link
Author

@ericf True that will work, but StringFormat handles all other numbers correctly except zero, so I was thinking it makes sense to support it for consistency.

@ericf
Copy link
Collaborator

ericf commented Jun 8, 2016

Using number also gives you formatting; e.g. "1,000 items".

I'm going to close this out as it's been brought up before and we decided against it.

@mimecuvalo
Copy link

Echoing what I said here: formatjs/formatjs#711
(not sure which project is appropriate)

Seeing that there's many dupes of this and it's for dev's to shoot themselves in the foot here: yahoo/intl-messageformat#88

Would it make sense at least when using a plural rule that it's implicitly treated as a number?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants