NumberWords
It is not realistic to expect a single maintainer to be sufficiently polyglottous to be able to manage a system for writing numbers as words in a variety of languages. Furthermore, the rules in various languages vary to such an extent that there is little use in attempting to impose a single framework (beyond a collection of utilities).
This gem provides a central point into which locale-specific number-to-word gems can hook.
Installation
The gems for the locales you support should depend on this gem, so under normal circumstances once you've installed those, this is installed also. For example, if you add
gem 'number_words_fr'
to your Gemfile, you'll have this gem too.
Usage
require 'number_words/core_ext'
I18n.locale = :fr
123.to_words # => "cent vingt-trois"
If you don't want to monkey-patch Integer, you can do this instead:
I18n.locale = :fr
NumberWords.int_to_words 123 # => "cent vingt-trois"
'number_words/core_ext' isn't "require"d by default
available locales
gem 'number_words_fr' # French
gem 'number_words_en' # English (using short-scale billions)
Contributing
There are two ways to contribute - firstly the usual:
- Fork it ( http://github.com/
/number_words/fork ) - Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
secondly
if you want to contribute a locale, make your own gem that plugs into this thus:
class RussianNumberWords def int_to_words i, options={} # ur code here end end
NumberWords.add_handler :ru, RussianNumberWords.new
publish the gem
let me know and I'll add a link here