Socket
Book a DemoInstallSign in
Socket

currency_to_words

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

currency_to_words

0.0.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

= Gem currency_to_words

Provides a view helper for Rails that translate a currency amount to words (eg. to_words(200) => 'dvě stě').

This helper comes with two supported locales (Czech and Polish) but it is possible and easy to implement your own (see "Implementing a new locale").

== Installation

Add the gem to your Gemfile.

gem 'currency_to_words'

== Usage

Install gem and create locale file in your project where you want to provide translation from currency to words. You can use locale file from I18n files below section or create your own.

== Examples

In your views write for example: currency_to_words(235.58)

== I18n files

=== Czech locale

cs: number: currency_in_words: format: '%n' options_precision: precision: 2 delimiter: '' significant: false strip_insignificant_zeros: false separator: '.' raise: false connector: ' a ' negative_format: '(%n)' skip_and: true ones: [nula, jedna, dvě, tři, čtyři, pět, šest, sedm, osm, devět] teens: [deset, jedenáct, dvanáct, třináct, čtrnáct, patnáct, šestnáct, sedmnáct, osmnáct, devatenáct] tens: [nil, nil,'dvacet','třicet','čtyřicet','padesát','šedesát','sedmdesát', 'osmdesát','devadesát'] hundreds: [sto, dvě stě, tři sta, čtyři sta, pět set, šest set, sedm set, osm set, devět set] thousands_ones: [, jeden, dva, tři, čtyři, pět, šest, sedm, osm, devět] megs: [, thousand, milion, bilion, trilion] thousand: one: 'tisíc' few: 'tisíce' other: 'tisíc' milion: one: 'milion' few: 'miliony' other: 'milionů' bilion: one: 'bilion' few: 'biliony' other: 'bilionů' trilion: one: 'trilion' few: 'triliony' other: 'trilionů' currencies: integer: one: 'koruna' few: 'koruny' other: 'korun' decimal: one: 'haléř' few: 'haléře' other: 'haléřů'

== Missing locale?

If you need locale that is not supported yet, you can easily add one. All you need to do is translated locale file and create class in /lib. Convention is that the class has to be named [locale]Currency.

So for example EnCurrency or FrCurrency. So override or duplicate the existing class and add diffrences of your language. Thats it!

== Inspiration

This project is heavily inspirated by {bcarrere/currency-in-words}[https://github.com/bcarrere/currency-in-words] and uses blocks of code from this repository.

Reason for creating my own repository was requirement to use I18n gem for "currency to words" translation and also for settings. This means, that this gem can be configured from locale file and translation is not hardcoded to source of library.

== Contribution

Did you created locales that is not supported here yet? Please write me e-mail if you want contribute at majak108@gmail.com.

== Copyright

Copyright (c) 2014 Jakub Malina. See LICENSE.txt for further details.

FAQs

Package last updated on 30 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.