A Ruby gem which converts decimal currency numbers into text in Bulgarian language. For use in financial applications, accounting documents, and all other instances requiring currency verbalization.
Handles the specifics of verbally presenting numbers and prices in Bulgarian, including grammatical irregularities, differences due to gender, singularity and plurality and the logic of using or omitting the "and" conjunction from the resulting string.
Ruby 1.9.3 or higher | Supports Ruby 2.0!
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install slovom
Just append the
.slovom method to the decimal (variable) you want to be presented verbally.
This will return a text string with the currency ammount (in levs) expressed verbally.
product1.price.to_s => "23.00" product1.price.slovom => "двадесет и три лева" product2.price.to_s => "1563.78" product2.price.slovom => "хиляда петстотин шестдесет и три лева и седемдесет и осем стотинки" product3.price.to_s => "0.75" product3.price.slovom => "седемдесет и пет стотинки" "76.03".to_d.slovom => "седемдесет и шест лева и три стотинки"
It parses numbers of up to 1 quadrillion (1000000000000000), as larger numbers are not likely to be used in financial transactions and hence no need to be expressed verbally. It returns the string "много" if higher number is used.
.slovom method is attached to the
BigDecimal class, which is also used by default for decimals in Rails.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Make sure all tests pass!
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
Copyright © 2013 Svilen Vassilev
Released under the MIT LICENSE