Coder Social home page Coder Social logo

humanize's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

humanize's Issues

consider changing the name?

"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

Wrong translation 446.humanize in locale :ru

 >>  Humanize.configure {|config| config.default_locale = :ru}
=> :ru
>> 446.humanize
=> "шесть"
>> 

Replace 'шесть' to 'четыреста сорок шесть' in lib/humanize/locales/constants/ru.rb, please...

-0.XXX is read incorrectly (without the 'negative')

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"

Float conversions break after 5 decimal places.

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.

Needs Configuration to Remove "and" Separating Large Numbers for Check Amount Fields

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.

cannot load such file -- [...]/humanize-1.2.0/lib/words

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.

Discussion: Shouldn't we Use I18n.locale by default?

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.

Gem based on Humanize

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.

Number 10**18 and above are breaking in Indonesian locale

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.

Decimals not being humanized for BigDecimal numbers

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"

Use of mutation testing in humanize - Help needed

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!!

ru locale support

Hi guys,

I'm adding support for Russian, and I've run into a couple of issues:

  1. A lot of language-specific rules. For example:
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?

  1. When I tried to replace words in the output string, I have faced an invalid byte sequence in UTF-8 error.

Thank you!

Error in /locales/constants/de.rb

POINT = 'Punkt'.freeze
should read
POINT = 'Komma'.freeze
quick-fix / monkey patch: In your Ruby Code use
Humanize::De::POINT = 'Komma'

Incompatible with Ruby 1.9 but no required_ruby_version in gemspec

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...
...                               ^

PT local suport

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).

Float numbers with zero

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

Possible to remove 'and' joining large numbers?

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

consider including money/currency?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.