radar / humanize Goto Github PK
View Code? Open in Web Editor NEWTakes your numbers and makes them *fancy*.
License: MIT License
Takes your numbers and makes them *fancy*.
License: MIT License
GitHub Actions automatic build fails during pre-build check.
Duplicate value "семьдесят восемь"
"humanize" is already an established well-known github project.. might confuse people. suggestions:
4.wordify
4.toWords
Also would be cool to have a reverse method to convert the string of words back to a Number
>> Humanize.configure {|config| config.default_locale = :ru}
=> :ru
>> 446.humanize
=> "шесть"
>>
Replace 'шесть' to 'четыреста сорок шесть' in lib/humanize/locales/constants/ru.rb, please...
Hi! I want to add es locales, there's a documentation to contribute?
Italian language, please
The negative
is not read when -1 < number
< 0.
-0.042.humanize
#=> "zero point zero four two"
-0.42.humanize
#=> "zero point four two"
It should behave like this, right?:
-0.042.humanize
#=> "negative zero point zero four two"
-0.42.humanize
#=> "negative zero point four two"
Repost the following comment:
#3 (comment)
as issue report.
0.0003.humanize
#=> "zero point zero zero zero three"
0.00003.humanize
#=> "zero point zero zero zero zero five"
# expected: "zero point zero zero zero zero three"
0.000003.humanize
#=> "zero point zero zero zero zero six"
# expected: "zero point zero zero zero zero zero three"
Update:
Btw, this issue only occurs when the number is 0.0000XXX
or -0.0000XXX
.
A nifty feature for this gem would be a configuration that allows you to choose whether or not you want "and" between large numbers (e.g. "Nine hundred Ninety Nine Thousand" vs "Nine Hundred and Ninety Nine Thousand").
When writing a check, it is generally good practice to only include "and" between the whole dollar amount and the fraction representing cents at the end so that it is clear where the dollars end and the cents begin, and this gem would be absolutely perfect for this use if not for the and's included in the output strings.
I just updated humanize to use it in my project and it crashed, saying it cannot locate the words.rb
file.
When I looked into the gem directory on my machine the words.rb
file was indeed missing. But it's present on the repo.
Do you have an idea why ? Might words
be a reserved word somehow ?
It is working when setting gem 'humanize', github: 'radar/humanize'
in my Gemfile
.
Maybe I'm missing something here, but I think that it would be useful if #humanize
would use current locale (I18n.locale
) by default when available.
One could still change to a different locale on a per-call basis by doing something like:
# the current way
n.humanize(locale: :es)
# or
I18n.with_locale(:es) do
n.humanize
end
, but I think that if your app/project has I18n, you'll probably want to use the current locale for humanizing numbers most of the times.
If it makes sense, I'd be happy to find some time to submit a PR with a proposal in the next couple of weeks.
Hi,
I forked your gem to build https://github.com/nexkap/humanize .
I added features such as the possibility to add different languages (english and french are available for now) and specify rounding options. The focus was not on the performance (my version is slower than yours) since I'm using this lib to generate documents in a delayed job but more on additional features.
It's still a first draft and will be updated in the coming days . However I was wondering if you'd be interested or not in a pull request since the code now differs a lot from your initial project . If you don't, please feel free to ask me to change the name of the project. You'll still have your name in the contributors and thanks list anyway.
Let me know.
Currently:
1_000_000_000_000_000_000.humanize(:locale => :id)
# => NoMethodError: undefined method `+' for nil:NilClass
If any of you Indonesians knows the name of these unnamed scales:
['', 'ribu', 'juta', 'miliar', 'triliun', 'kuadriliun', 1018, 1021, 1024, 1027, 'kuintiliun', 'desiliun', 1036, .. ],
please let us know in the comments or send us a PR.
As you can see, I've found the names of 1030 and 1033. But it supposed to be contiguous so that it wouldn't break.
It seems there is a problem generating the humanized version of BigDecimal decimal part.
-> % irb
irb(main):001:0> require 'humanize'
=> true
irb(main):002:0> 123.45.humanize
=> "one hundred and twenty-three point four five"
irb(main):003:0> BigDecimal.new("123.45")
=> 0.12345e3
irb(main):004:0> BigDecimal.new("123.45").humanize
=> "one hundred and twenty-three"
Hello there!
My name is Ana. I noted that you use the mutation testing tool mutant in the project.
I am a postdoctoral researcher at the University of Seville (Spain), and my colleagues and I are studying how mutation testing tools are used in practice. With this aim in mind, we have analysed over 3,500 public GitHub repositories using mutation testing tools, including yours! This work has recently been published in a journal paper available at https://link.springer.com/content/pdf/10.1007/s10664-022-10177-8.pdf.
To complete this study, we are asking for your help to understand better how mutation testing is used in practice, please! We would be extremely grateful if you could contribute to this study by answering a brief survey of 21 simple questions (no more than 6 minutes). This is the link to the questionnaire https://forms.gle/FvXNrimWAsJYC1zB9.
Drop me an e-mail if you have any questions or comments ([email protected]). Thank you very much in advance!!
Hi guys,
I'm adding support for Russian, and I've run into a couple of issues:
1000.humanize
# => "одна тысяча"
2000.humanize
# => "две тысячи"
5000.humanize
# => "пять тысяч"
I can search the output string for a specific combination of words, and then replace it with the right ones but this solution will be relatively slow since it requires an iteration through a pretty big list of combinations.
Maybe there's a better way?
invalid byte sequence in UTF-8
error.Thank you!
POINT = 'Punkt'.freeze
should read
POINT = 'Komma'.freeze
quick-fix / monkey patch: In your Ruby Code use
Humanize::De::POINT = 'Komma'
Starting with v1.2.0, humanize fails on Ruby versions prior to 2.0 because of non ASCII characters added to files like lots.rb
without encoding comments. But the gemspec doesn't state a required Ruby version, so this issue isn't found until trying to load the code that Rubygems has already installed.
humanize-1.2.2/lib/lots.rb:3: syntax error, unexpected $end, expecting ']'
...'nonillion', 'nonilliard', 'décillion', 'décilliard', 'und...
... ^
I am currently developing a system, and one of the feature is converting numbers into text. Then I would like to contribute to the project by adding support for PT (Portuguese).
Hi,
First of all thanks for grete gem
We have problem with next example
0.042.humanize(decimals_as: :number)
# "zero point forty-two"
It take's string "042".to_i and then convert it to words.
I think in this case we must detect zero
I noticed the same issue here #14, but I don't see a way to override this. According to the code below this doesn't seem possible anymore. Am I missing something?
def conjunction(parts, use_and)
return '' if parts.empty?
use_and ? ' and' : ','
end
Similar to decimal/float but instead of "x point y", it'd be "x [currency] and y [currency]" (for English at least)
0.42.humanize(decimals_as: :currency) # => "forty-two cents"
1.42.humanize(decimals_as: :currency) # => "one dollar and forty-two cents"
What do you think?
It would be fantastic if this supported "first", "second", "third", "etc".... thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.