luckyframework / luckyframework/lucky
number_to_human helper method
Open
Nobody has claimed this yet.
feature request
- Dominant language
- Crystal
- Stars
- 2.7k
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Description
In rails, I have this method
format = number_only ? "%n%u" : "%n%u #{thing.pluralize(number)}"
number_to_human(
number,
format: format,
precision: 2,
units: {
thousand: 'k',
million: 'm'
}
)
Which allows me to output something like "1.5k Users". The closest we have right now is something like:
text count.humanize
text pluralize(count, "User")
which would output "1.5k 1500 Users". It would be nice to have this helper method added in.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing humanize and pluralize helpers referenced in the issue, then inspect how helper methods are organized. The work is done when a number_to_human helper can format values such as 1.5k Users while supporting the shown format, precision, units, and singular or plural output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100