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

Feature request: positive/negative "pluralization" #678

Closed
k5cents opened this issue Mar 14, 2024 · 1 comment
Closed

Feature request: positive/negative "pluralization" #678

k5cents opened this issue Mar 14, 2024 · 1 comment

Comments

@k5cents
Copy link

k5cents commented Mar 14, 2024

It would be cool if you could use the pluralization formatting to provide alternative text based on whether the preceding value is positive or negative.

For example, if the value is positive use the word "more". If the value is negative use the word "fewer".

diff <- 10
cli_alert_inform("Count has {diff} {?fewer/more} records")
#> Count has 10 more records

diff <- -5
cli_alert_inform("Count has {diff} {?fewer/more} records")
# either with or without negative symbol
#> Count has 5 fewer records
#> Count has -5 fewer records
@gaborcsardi
Copy link
Member

I am not sure how common this is, but is would also interfere with the current pluralization.

Nevertheless you can already do this, which is not too bad:

diff <- 10
cli_alert("Count has {diff} {ifelse(diff < 0, 'fewer', 'more')} records.")
#> → Count has 10 more records.

@k5cents k5cents closed this as completed Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants