Translates numbers to Polish words.
To build the gem:
gem build polish_number.gemspec
To publish into Nexus repository:
gem install nexus # if not already installed
gem nexus polish_number-<version>.gem # replace <version> with actual version The Nexus gem will ask for Nexus URL and credentials for the first time. For in4mates the URL is: https://nexus.in4mates.com/repository/in4mates-gems/
Add this line to your application's Gemfile:
gem 'polish_number'
Note: in the past known as polish-number (dash instead of an underscore) -- before version 1.0.0. Old repo: https://github.com/wpiekutowski/polish-number
And then execute:
$ bundle
Or install it yourself as:
$ gem install polish_number
require 'polish_number'
PolishNumber.translate(1234) #=> tysiąc dwieście trzydzieści cztery
PolishNumber.translate(34, :currency => :PLN) #=> trzydzieści cztery złote
PolishNumber.translate(12, :currency => :PLN) #=> dwanaście złotych
PolishNumber.translate(1234, :currency => :USD) #=> tysiąc dwieście trzydzieści cztery dolary amerykańskie
PolishNumber.translate(1, :currency => :USD) #=> jeden dolar amerykański
PolishNumber.translate(12, :currency => :USD) #=> dwanaście dolarów amerykańskich
PolishNumber.translate(34.11) #=> trzydzieści cztery i jedenaście setnych
PolishNumber.translate(30.01, :currency => :PLN) #=> trzydzieści złote i jeden grosz
PolishNumber.translate(0.10, :currency => :PLN) #=> dziesięć groszy
PolishNumber.translate(5.10, :currency => :PLN, :cents => :no ) #=> pięć złotych
PolishNumber.translate(5, :currency => :PLN, :cents => :words ) #=> pięć złotych zero groszy
PolishNumber.translate(5, :currency => :PLN, :cents => :digits ) #=> pięć złotych 00/100
PolishNumber.add_currency(:COWS, { :one => 'krowa', :few => 'krowy',
:many => 'krów', :gender => :she,
:one_100 => 'ser', :few_100 => 'sery',
:many_100 => 'serów', :gender_100 => :hi})
PolishNumber.translate(35.05, :currency => :COWS) #=> trzydzieści pięć krów i pięć serów
The gem translate ordinal numbers in 0..99 range for all cases (nominative, genitive, dative, accusative, instrumental, locative, vocative) and all gender (masculine, feminine, neuter, masculine_personal, non_masculine) For masculine_personal gender and nominative/vocative case number should be in 0..4 range
PolishNumber.translate_ordinal(34, :grammatical_case => :nominative, :gender => :masculine) #=> trzydziesty czwarty
PolishNumber.translate_ordinal(18, :grammatical_case => :dative, :gender => :feminine) #=> osiemnastej
PolishNumber.translate_ordinal(20, :grammatical_case => :instrumental, :gender => :neuter) #=> dwudziestym
PolishNumber.translate_ordinal(2, :grammatical_case => :nominative, :gender => :masculine_personal) #=> drudzy
PolishNumber.translate(1000000001, :officially => true) #=> jeden miliard jeden
PolishNumber.translate(1001001001, :officially => true) #=> jeden miliard jeden milion jeden tysiąc jeden
PolishNumber.translate(2001000, :officially => true) #=> dwa miliony jeden tysiąc
- Fork it
- 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

