Word Pluralization and Conversions from Numbers like 1,2,3,4,5

Anyone knows if standard ruby has this available?

5.en.numwords # => “five”
1.en.numwords # => “one”

This is part of the Linguistics gem, but I wonder why
standard Ruby does not have this available?

To be able to convert “5” to “five” seems useful
everytime I want to output something to the user
containing words in english:

x = 5

puts “You eat #{x} cows.”

“You eat 5 cows.”

puts “You eat #{x.en.numwords} cows.”

“You eat five cows.”

On Tue, Dec 25, 2012 at 4:41 AM, Marc H. [email protected]
wrote:

Anyone knows if standard ruby has this available?

5.en.numwords # => “five”
1.en.numwords # => “one”

This is part of the Linguistics gem, but I wonder why
standard Ruby does not have this available?

I am guessing that translation and natural language handling are not
considered basic i18n functionality. That makes a whole lot of sense
if you consider that it is complicated and there are usually a lot
different possible approaches. Whichever you put into the core or
standard library you will only help part of the Ruby population.
Using a gem for this does not seem to be such a bad alternative.

To be able to convert “5” to “five” seems useful
everytime I want to output something to the user.

Well, you could create a poor man’s version if you feel the gem is too
heavyweight:

NUMBERS =%w[zero one two three four five six seven eight nine]

puts NUMBERS[5]

:wink:

Kind regards

robert

And English gem.