Skip to content

Translates numbers to Polish words

License

MIT, GPL-2.0 licenses found

Licenses found

MIT
LICENSE.txt
GPL-2.0
COPYING
Notifications You must be signed in to change notification settings

ipepe/polish_number

 
 

Repository files navigation

Polish Number Code Climate Build Status Test Coverage

Translates numbers to Polish words.

Installation

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

Usage

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

Fractions format

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, :fractions => :none) #=> pięć złotych
PolishNumber.translate(5, :currency => :PLN, :fractions => :words) #=> pięć złotych zero groszy
PolishNumber.translate(5, :currency => :PLN, :fractions => :digits) #=> pięć złotych 00/100

Adding new currencies

PolishNumber.add_currency(:COWS, { :one => 'krowa', :few => 'krowy',
  :many => 'krów', :gender => :female,
  :one_100 => 'ser', :few_100 => 'sery',
  :many_100 => 'serów', :gender_100 => :male})

PolishNumber.translate(35.05, :currency => :COWS) #=> trzydzieści pięć krów i pięć serów

Changelog

  • 1.2.0 - Added billions support. Fixed multiple bugs. Added changelog to readme. Added support for genders in currencies. Added support for hundredth parts of number.(setne i grosze) Remove "jeden" from million and thousand when only one. Added support for adding new currencies.
  • 1.1.0 - First changeloged version

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Analytics

About

Translates numbers to Polish words

Resources

License

MIT, GPL-2.0 licenses found

Licenses found

MIT
LICENSE.txt
GPL-2.0
COPYING

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 99.5%
  • Shell 0.5%