Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Plural rules are broken for time diff strings #3495

Closed
TheoChevalier opened this issue Sep 14, 2017 · 3 comments
Closed

Plural rules are broken for time diff strings #3495

TheoChevalier opened this issue Sep 14, 2017 · 3 comments
Assignees
Labels
l10n Something related to localization / internationalization

Comments

@TheoChevalier
Copy link
Contributor

Screenshot of timeDiffHoursAgo in French https://screenshots.firefox.com/T7g56E2IcYW6yQkK/screenshots.firefox.com

According to the translation here, it should be 1 heure (without s) https://pontoon.mozilla.org/fr/firefox-screenshots/server.ftl/?search=timeDiffHoursAgo&string=168527

Flod pointed that there might be a problem here

return <Localized id={timeDiff.l10nID} $number={timeDiff.diff}><span title={this.dateString(this.props.date)}></span></Localized>

CC: @stasm @flodolo

@ghost ghost added this to the General Release 57 milestone Sep 15, 2017
@ghost ghost added the l10n Something related to localization / internationalization label Sep 21, 2017
@jaredhirsch jaredhirsch self-assigned this Oct 4, 2017
@jaredhirsch
Copy link
Member

@stasm Is it intended that passing the number 1 chooses the "one" plural, but passing the string "1" chooses the default, rather than coercing the string to a number?

this behavior is visible in the fluent playground:

"1" as a string:

1 as a number:

@ianb ianb closed this as completed in 3b0a99e Oct 10, 2017
ianb added a commit that referenced this issue Oct 10, 2017
Fix #3495, Fix pluralization by passing integer time diffs as numbers, not strings
@stasm
Copy link
Contributor

stasm commented Oct 11, 2017

Oops, sorry I missed the notification here. I'm happy I didn't block you from fixing this.

To answer @6a68's question: yes, this is the intended behavior for two reasons:

  • It's more flexible that way: developers can choose to parseInt. If Fluent coerced, developers wouldn't be able to choose not to.
  • Some locales use different plural forms for integers and decimals, e.g. 1 is different from 1.0. I think English is one of them: 1 apple but 1.0 apples. The only way in JS to pass 1.0 and not lose the decimal part is to pass it as a string. (That said, fluent.js doesn't yet correctly support such numbers.)

@jaredhirsch
Copy link
Member

@stasm Nah, not a problem. Good point re: decimal singular, I hadn't considered that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
l10n Something related to localization / internationalization
Projects
None yet
Development

No branches or pull requests

3 participants