numbers_and_words 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -2
- data/README.md +369 -0
- data/bin/to_words +6 -0
- data/lib/numbers_and_words/cli.rb +127 -0
- data/lib/numbers_and_words/compatibility.rb +98 -0
- data/lib/numbers_and_words/config.rb +63 -0
- data/lib/numbers_and_words/core_ext/array.rb +5 -1
- data/lib/numbers_and_words/core_ext/float.rb +4 -1
- data/lib/numbers_and_words/core_ext/integer.rb +4 -1
- data/lib/numbers_and_words/fallback.rb +46 -0
- data/lib/numbers_and_words/i18n/initialization.rb +23 -2
- data/lib/numbers_and_words/i18n/legacy/numbers.kz.yml +4 -0
- data/lib/numbers_and_words/i18n/legacy/numbers.se.yml +4 -0
- data/lib/numbers_and_words/i18n/legacy/numbers.ua.yml +4 -0
- data/lib/numbers_and_words/i18n/locales/numbers.ar.yml +37 -0
- data/lib/numbers_and_words/i18n/locales/numbers.az.yml +27 -0
- data/lib/numbers_and_words/i18n/locales/numbers.bg.yml +78 -0
- data/lib/numbers_and_words/i18n/locales/numbers.bn.yml +112 -0
- data/lib/numbers_and_words/i18n/locales/numbers.cs.yml +33 -13
- data/lib/numbers_and_words/i18n/locales/numbers.da.yml +47 -28
- data/lib/numbers_and_words/i18n/locales/numbers.de.yml +9 -2
- data/lib/numbers_and_words/i18n/locales/numbers.el.yml +36 -0
- data/lib/numbers_and_words/i18n/locales/numbers.en-GB.yml +4 -0
- data/lib/numbers_and_words/i18n/locales/numbers.en.yml +5 -1
- data/lib/numbers_and_words/i18n/locales/numbers.es.yml +9 -0
- data/lib/numbers_and_words/i18n/locales/numbers.et.yml +33 -17
- data/lib/numbers_and_words/i18n/locales/numbers.fi.yml +20 -0
- data/lib/numbers_and_words/i18n/locales/numbers.fr-CH.yml +12 -2
- data/lib/numbers_and_words/i18n/locales/numbers.fr.yml +12 -2
- data/lib/numbers_and_words/i18n/locales/numbers.he.yml +29 -0
- data/lib/numbers_and_words/i18n/locales/numbers.hi.yml +116 -0
- data/lib/numbers_and_words/i18n/locales/numbers.hu.yml +6 -0
- data/lib/numbers_and_words/i18n/locales/numbers.hy.yml +8 -1
- data/lib/numbers_and_words/i18n/locales/numbers.id.yml +16 -0
- data/lib/numbers_and_words/i18n/locales/numbers.it.yml +121 -2
- data/lib/numbers_and_words/i18n/locales/numbers.ja.yml +19 -0
- data/lib/numbers_and_words/i18n/locales/numbers.ka.yml +10 -2
- data/lib/numbers_and_words/i18n/locales/numbers.kk.yml +28 -0
- data/lib/numbers_and_words/i18n/locales/numbers.ko.yml +8 -0
- data/lib/numbers_and_words/i18n/locales/numbers.lt.yml +58 -6
- data/lib/numbers_and_words/i18n/locales/numbers.lv.yml +54 -2
- data/lib/numbers_and_words/i18n/locales/numbers.ms.yml +16 -0
- data/lib/numbers_and_words/i18n/locales/numbers.nb.yml +60 -0
- data/lib/numbers_and_words/i18n/locales/numbers.nl.yml +28 -15
- data/lib/numbers_and_words/i18n/locales/numbers.pl.yml +66 -0
- data/lib/numbers_and_words/i18n/locales/numbers.pt-BR.yml +15 -9
- data/lib/numbers_and_words/i18n/locales/numbers.pt.yml +68 -12
- data/lib/numbers_and_words/i18n/locales/numbers.ro.yml +52 -0
- data/lib/numbers_and_words/i18n/locales/numbers.ru.yml +312 -6
- data/lib/numbers_and_words/i18n/locales/numbers.sk.yml +32 -0
- data/lib/numbers_and_words/i18n/locales/numbers.sv.yml +54 -0
- data/lib/numbers_and_words/i18n/locales/numbers.th.yml +10 -0
- data/lib/numbers_and_words/i18n/locales/numbers.tr.yml +14 -0
- data/lib/numbers_and_words/i18n/locales/numbers.uk.yml +397 -0
- data/lib/numbers_and_words/i18n/locales/numbers.ur.yml +116 -0
- data/lib/numbers_and_words/i18n/locales/numbers.vi.yml +6 -1
- data/lib/numbers_and_words/i18n/locales/numbers.zh.yml +9 -0
- data/lib/numbers_and_words/i18n/pluralization.rb +7 -20
- data/lib/numbers_and_words/i18n/plurals/ar.rb +26 -0
- data/lib/numbers_and_words/i18n/plurals/pl.rb +18 -0
- data/lib/numbers_and_words/i18n/plurals/plurals.rb +2 -2
- data/lib/numbers_and_words/i18n/plurals/ro.rb +21 -0
- data/lib/numbers_and_words/i18n/plurals/sk.rb +21 -0
- data/lib/numbers_and_words/i18n/plurals/{ua.rb → uk.rb} +3 -1
- data/lib/numbers_and_words/i18n.rb +29 -3
- data/lib/numbers_and_words/options_validation.rb +89 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/{ua.rb → az.rb} +1 -1
- data/lib/numbers_and_words/strategies/{figures_converter/languages/se.rb → array_joiner/languages/bg.rb} +2 -2
- data/lib/numbers_and_words/strategies/array_joiner/languages/bn.rb +13 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/de.rb +16 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/decimal_point.rb +23 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/el.rb +13 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/en-GB.rb +1 -7
- data/lib/numbers_and_words/strategies/array_joiner/languages/en.rb +1 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/families/indian.rb +19 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/fi.rb +16 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/fr-CH.rb +1 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/fr.rb +1 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/he.rb +16 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/hi.rb +13 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/id.rb +13 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/it.rb +13 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/ja.rb +32 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/ko.rb +17 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/ms.rb +13 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/nb.rb +16 -0
- data/lib/numbers_and_words/strategies/{figures_converter/languages/kz.rb → array_joiner/languages/pl.rb} +2 -2
- data/lib/numbers_and_words/strategies/array_joiner/languages/pt-BR.rb +1 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/pt.rb +13 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/ro.rb +13 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/sk.rb +12 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/th.rb +21 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/uk.rb +12 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/ur.rb +13 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/vi.rb +4 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/zh.rb +21 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages.rb +24 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/{ua → az}/base.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/az/fractional.rb +41 -0
- data/lib/numbers_and_words/strategies/figures_converter/{languages/ua.rb → decorators/az/integral.rb} +4 -3
- data/lib/numbers_and_words/strategies/figures_converter/decorators/{ua.rb → az.rb} +3 -3
- data/lib/numbers_and_words/strategies/figures_converter/decorators/bg/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/bg/fractional.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/bg/integral.rb +22 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/bg.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/bn/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/bn/fractional.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/bn/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/bn.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/de/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/de/fractional.rb +30 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/de/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/de.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/decimal_point.rb +44 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/el/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/el/fractional.rb +27 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/el/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/el.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en/fractional.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/fractional.rb +0 -15
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fi/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fi/fractional.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fi/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fi.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/fractional.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/he/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/he/fractional.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/he/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/he.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hi/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hi/fractional.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hi/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hi.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/base.rb +7 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/fractional.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/integral.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/id/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/id/fractional.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/id/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/id.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/indian.rb +21 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/it/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/it/fractional.rb +58 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/it/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/it.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ja/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ja/fractional.rb +18 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ja/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ja.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ko/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ko/fractional.rb +18 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ko/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ko.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ms/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ms/fractional.rb +15 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ms/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ms.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/nb/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/nb/fractional.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/nb/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/nb.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pl/fractional.rb +19 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pl/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pl.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pt/fractional.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pt/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/fractional.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/integral.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pt.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ro/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ro/fractional.rb +27 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ro/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ro.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/integral.rb +3 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/sk/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/sk/fractional.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/sk/integral.rb +22 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/sk.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/th/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/th/fractional.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/th/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/th.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/uk/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/{ua → uk}/fractional.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/{ua → uk}/integral.rb +4 -2
- data/lib/numbers_and_words/strategies/figures_converter/decorators/uk.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ur/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ur/fractional.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ur/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ur.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/zh/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/zh/fractional.rb +18 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/zh/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/zh.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators.rb +31 -4
- data/lib/numbers_and_words/strategies/figures_converter/languages/ar.rb +113 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/az.rb +41 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/bg.rb +130 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/bn.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/cases.rb +64 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/cs.rb +28 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/da.rb +29 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/de.rb +41 -4
- data/lib/numbers_and_words/strategies/figures_converter/languages/el.rb +108 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/en-GB.rb +8 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/en.rb +7 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/es.rb +35 -2
- data/lib/numbers_and_words/strategies/figures_converter/languages/et.rb +42 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/helpers.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/indian.rb +75 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/fi.rb +113 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/fr.rb +58 -2
- data/lib/numbers_and_words/strategies/figures_converter/languages/he.rb +112 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/hi.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/hu.rb +31 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/hy.rb +23 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/id.rb +79 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/it.rb +132 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/ja.rb +41 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/ka.rb +27 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/kk.rb +27 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/ko.rb +33 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/lt.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/lv.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/ms.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/myriad.rb +58 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/nb.rb +108 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/nl.rb +14 -2
- data/lib/numbers_and_words/strategies/figures_converter/languages/ordinals.rb +155 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/pl.rb +39 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/pt-BR.rb +12 -8
- data/lib/numbers_and_words/strategies/figures_converter/languages/pt.rb +103 -2
- data/lib/numbers_and_words/strategies/figures_converter/languages/ro.rb +117 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/ru.rb +16 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/sk.rb +144 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/sv.rb +67 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/th.rb +55 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/tr.rb +7 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/uk.rb +29 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/ur.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/vi.rb +19 -14
- data/lib/numbers_and_words/strategies/figures_converter/languages/zh.rb +57 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages.rb +26 -3
- data/lib/numbers_and_words/strategies/figures_converter/options/ar/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/{ua.rb → ar.rb} +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/az/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/az/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/az.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/base/animate.rb +30 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/base/fraction.rb +16 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/bg/gender.rb +16 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/bg/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/bg/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/bg.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/bn/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/bn/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/bn.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/cs/gender.rb +4 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/da/gender.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/da/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/da.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/de/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/de/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/de.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/el/gender.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/el/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/el/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/el.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en/fraction.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb +11 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/fraction.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/hundreds_with_union.rb +6 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB.rb +2 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/en.rb +2 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/es/gender.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/es/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/es.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/et/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/et.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fi/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fi/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fi.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fr/fraction.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fr/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fr/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fr/spelling.rb +25 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fr-CH/fraction.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fr-CH/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fr-CH/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fr-CH/spelling.rb +15 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fr-CH.rb +6 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/fr.rb +6 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/he/gender.rb +20 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/he/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/he/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/he.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hi/gender.rb +16 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hi/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hi/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hi.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hu/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hu.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hy/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hy.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/id/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/id/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/id.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/it/fraction.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/it/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/it/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/it.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ja/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ja/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ja/script.rb +25 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ja.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ka/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ka.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/kk/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/kk.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ko/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ko/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ko.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/lt/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/lt.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/lv/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/lv.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ms/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ms/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ms.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/nb/gender.rb +16 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/nb/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/nb/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/nb.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/nl/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/nl/pronounced.rb +26 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/nl/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/nl.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pl/gender.rb +22 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pl/ordinal.rb +21 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pl/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pl.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pt/fraction.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/{ua → pt}/gender.rb +2 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/pt/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pt/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/fraction.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/gender.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pt.rb +6 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ro/gender.rb +17 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ro/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ro/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ro.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ru/animate.rb +15 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ru/case.rb +16 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ru/gender.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ru/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ru/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ru.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/sk/gender.rb +16 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/sk/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/sk/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/sk.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/sv/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/sv.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/th/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/th/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/th.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/tr/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/tr.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/uk/animate.rb +15 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/uk/case.rb +16 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/uk/gender.rb +15 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/uk/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/uk/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/uk.rb +7 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ur/gender.rb +16 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ur/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ur/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ur.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/vi/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/vi/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/vi.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/zh/ordinal.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/zh/remove_zero.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/zh.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options.rb +38 -3
- data/lib/numbers_and_words/translations/ar.rb +32 -0
- data/lib/numbers_and_words/translations/az.rb +17 -0
- data/lib/numbers_and_words/translations/bg.rb +25 -0
- data/lib/numbers_and_words/translations/{kz.rb → bn.rb} +2 -2
- data/lib/numbers_and_words/translations/cs.rb +11 -1
- data/lib/numbers_and_words/translations/el.rb +35 -0
- data/lib/numbers_and_words/translations/et.rb +2 -0
- data/lib/numbers_and_words/translations/extensions/fraction_significance.rb +10 -1
- data/lib/numbers_and_words/translations/extensions/portuguese_fractions.rb +32 -0
- data/lib/numbers_and_words/translations/families/base.rb +17 -3
- data/lib/numbers_and_words/translations/families/indian.rb +28 -0
- data/lib/numbers_and_words/translations/fi.rb +12 -0
- data/lib/numbers_and_words/translations/fr.rb +1 -1
- data/lib/numbers_and_words/translations/he.rb +37 -0
- data/lib/numbers_and_words/translations/hi.rb +9 -0
- data/lib/numbers_and_words/translations/hu.rb +10 -1
- data/lib/numbers_and_words/translations/id.rb +23 -0
- data/lib/numbers_and_words/translations/it.rb +14 -2
- data/lib/numbers_and_words/translations/ja.rb +56 -0
- data/lib/numbers_and_words/translations/{se.rb → kk.rb} +4 -3
- data/lib/numbers_and_words/translations/ko.rb +23 -0
- data/lib/numbers_and_words/translations/ms.rb +9 -0
- data/lib/numbers_and_words/translations/nb.rb +12 -0
- data/lib/numbers_and_words/translations/pl.rb +8 -0
- data/lib/numbers_and_words/translations/pt-BR.rb +1 -18
- data/lib/numbers_and_words/translations/pt.rb +13 -4
- data/lib/numbers_and_words/translations/ro.rb +40 -0
- data/lib/numbers_and_words/translations/sk.rb +33 -0
- data/lib/numbers_and_words/translations/sv.rb +23 -0
- data/lib/numbers_and_words/translations/th.rb +23 -0
- data/lib/numbers_and_words/translations/{ua.rb → uk.rb} +1 -1
- data/lib/numbers_and_words/translations/ur.rb +9 -0
- data/lib/numbers_and_words/translations/zh.rb +19 -0
- data/lib/numbers_and_words/translations.rb +24 -3
- data/lib/numbers_and_words/unit/amount.rb +50 -0
- data/lib/numbers_and_words/unit/apocope.rb +18 -0
- data/lib/numbers_and_words/unit/before_noun.rb +35 -0
- data/lib/numbers_and_words/unit/order.rb +38 -0
- data/lib/numbers_and_words/unit/scale_preposition.rb +40 -0
- data/lib/numbers_and_words/unit.rb +148 -0
- data/lib/numbers_and_words/version.rb +1 -1
- data/lib/numbers_and_words/wrappers/float.rb +28 -7
- data/lib/numbers_and_words/wrappers/integer.rb +1 -7
- data/lib/numbers_and_words/wrappers/sign.rb +27 -0
- data/lib/numbers_and_words/wrappers.rb +18 -0
- data/lib/numbers_and_words.rb +5 -0
- metadata +347 -70
- data/README.rdoc +0 -428
- data/lib/numbers_and_words/i18n/locales/numbers.kz.yml +0 -7
- data/lib/numbers_and_words/i18n/locales/numbers.se.yml +0 -7
- data/lib/numbers_and_words/i18n/locales/numbers.ua.yml +0 -89
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3b1d0985b1d262b3a78fde2e6c1c342d6d0eaa59b0e9bd785f63d13929f62041
|
|
4
|
+
data.tar.gz: 4fe154a8cf9a28f17cff59122b2c1b498976f89310186ce93fa8ccbf2d209e09
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6807ba34c9ff66636820c673d18a428f8b4a044d0c3a63034909ea4b63d97a242939bc6b88aaa7d4405b0dab3e806c1cacafc6132a7372fee5f2b8ef38475752
|
|
7
|
+
data.tar.gz: 18c604ec45b296d7617681a00161dd3be0666e422ad2fe7575364417452363d7c09b925fbd7c1e71596b7232eb89ca6f1892d9ded8efbb32199fe750ac9356bc
|
data/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,64 @@
|
|
|
1
|
-
## 1.0
|
|
1
|
+
## 1.1.0 (2026/11/22)
|
|
2
2
|
|
|
3
3
|
### Features
|
|
4
|
-
*
|
|
4
|
+
* Add support for Ruby 4.0. \[[#211](https://github.com/kslazarev/numbers_and_words/pull/211)\]
|
|
5
|
+
* Improve Italian number conversion and floating-point support. \[[#215](https://github.com/kslazarev/numbers_and_words/pull/215)\]
|
|
6
|
+
* Run tests, lint and package checks in separate CI workflows, report coverage to Coveralls, and pin RuboCop. \[[#218](https://github.com/kslazarev/numbers_and_words/pull/218), [#239](https://github.com/kslazarev/numbers_and_words/pull/239), [#238](https://github.com/kslazarev/numbers_and_words/pull/238)\] \([@dblock](https://github.com/dblock)\)
|
|
7
|
+
* Add conversion benchmarks and reduce allocations. \[[#221](https://github.com/kslazarev/numbers_and_words/pull/221), [#222](https://github.com/kslazarev/numbers_and_words/pull/222)\] \([@dblock](https://github.com/dblock)\)
|
|
8
|
+
* Replace Jeweler with a static gemspec, and release with ruby-gem-release. \[[#219](https://github.com/kslazarev/numbers_and_words/pull/219)\] \([@dblock](https://github.com/dblock)\)
|
|
9
|
+
* Remove the i18n version constraint and test i18n 1.6. \[[#237](https://github.com/kslazarev/numbers_and_words/pull/237)\] \([@dblock](https://github.com/dblock)\)
|
|
10
|
+
* Add UPGRADING.md, AGENTS.md and a page per language in docs/languages with every option, and check every documented example in specs. \[[#256](https://github.com/kslazarev/numbers_and_words/pull/256), [#259](https://github.com/kslazarev/numbers_and_words/pull/259), [#260](https://github.com/kslazarev/numbers_and_words/pull/260), [#261](https://github.com/kslazarev/numbers_and_words/pull/261), [#270](https://github.com/kslazarev/numbers_and_words/pull/270), [#278](https://github.com/kslazarev/numbers_and_words/pull/278)\] \([@dblock](https://github.com/dblock)\)
|
|
11
|
+
* Add French and Swiss French `spelling: :reformed` for the 1990 reform (`trois-cent-vingt-et-un`), and `spelling: :traditional`, the default until 2.0. \[[#257](https://github.com/kslazarev/numbers_and_words/pull/257), [#282](https://github.com/kslazarev/numbers_and_words/pull/282)\] \([@dblock](https://github.com/dblock)\)
|
|
12
|
+
* Add experimental Polish, with gender, decimals and ordinals, completing #189. \[[#228](https://github.com/kslazarev/numbers_and_words/pull/228)\] \([@sectasy0](https://github.com/sectasy0), [@dblock](https://github.com/dblock)\)
|
|
13
|
+
* Add German ordinals and decimals ("Komma"), and fix German milliards and larger. \[[#232](https://github.com/kslazarev/numbers_and_words/pull/232)\] \([@dblock](https://github.com/dblock)\)
|
|
14
|
+
* Warn about options or values a language doesn't support, which 2.0 will reject with `NumbersAndWords::UnsupportedOptionError`. \[[#269](https://github.com/kslazarev/numbers_and_words/pull/269)\] \([@dblock](https://github.com/dblock)\)
|
|
15
|
+
* Add a `to_words` command. \[[#231](https://github.com/kslazarev/numbers_and_words/pull/231)\] \([@dblock](https://github.com/dblock)\)
|
|
16
|
+
* Select the bundled locales to load with `NumbersAndWords.configure` or `NumbersAndWords.config.locales`, completing #136. \[[#226](https://github.com/kslazarev/numbers_and_words/pull/226), [#277](https://github.com/kslazarev/numbers_and_words/pull/277)\] \([@seniorihor](https://github.com/seniorihor), [@dblock](https://github.com/dblock)\)
|
|
17
|
+
* Add Dutch `pronounced: true` (1910 is `negentienhonderd tien`). \[[#224](https://github.com/kslazarev/numbers_and_words/pull/224)\] \([@Wessel-Boers](https://github.com/Wessel-Boers), [@dblock](https://github.com/dblock)\)
|
|
18
|
+
* Add experimental Thai. \[[#276](https://github.com/kslazarev/numbers_and_words/pull/276)\] \([@brajo083](https://github.com/brajo083), [@dblock](https://github.com/dblock)\)
|
|
19
|
+
* Add a project logo. \[[#274](https://github.com/kslazarev/numbers_and_words/pull/274)\] \([@dblock](https://github.com/dblock)\)
|
|
20
|
+
* Add a `fallback` option and `NumbersAndWords.config.fallback` for unsupported locales, and raise `NumbersAndWords::UnsupportedLanguageError`, a `RuntimeError`, otherwise. \[[#234](https://github.com/kslazarev/numbers_and_words/pull/234), [#293](https://github.com/kslazarev/numbers_and_words/pull/293)\] \([@dblock](https://github.com/dblock)\)
|
|
21
|
+
* Support `remove_zero` in every language with decimals. \[[#284](https://github.com/kslazarev/numbers_and_words/pull/284)\] \([@dblock](https://github.com/dblock)\)
|
|
22
|
+
* Add Indonesian, and experimental Arabic, Bengali, Bulgarian, Chinese, Finnish, Greek, Hebrew, Hindi, Japanese, Korean, Malay, Norwegian Bokmål, Romanian, Slovak and Urdu. \[[#286](https://github.com/kslazarev/numbers_and_words/pull/286), [#287](https://github.com/kslazarev/numbers_and_words/pull/287), [#288](https://github.com/kslazarev/numbers_and_words/pull/288), [#301](https://github.com/kslazarev/numbers_and_words/pull/301), [#304](https://github.com/kslazarev/numbers_and_words/pull/304), [#305](https://github.com/kslazarev/numbers_and_words/pull/305), [#306](https://github.com/kslazarev/numbers_and_words/pull/306)\] \([@dblock](https://github.com/dblock)\)
|
|
23
|
+
* Support `ordinal: true` in every language. \[[#283](https://github.com/kslazarev/numbers_and_words/pull/283), [#291](https://github.com/kslazarev/numbers_and_words/pull/291), [#297](https://github.com/kslazarev/numbers_and_words/pull/297)\] \([@dblock](https://github.com/dblock)\)
|
|
24
|
+
* Add `fraction: false` to read decimals with a decimal point in English, French, Italian and Portuguese (`twenty-one point seven seven`), and `fraction: true`, the default until 2.0. \[[#289](https://github.com/kslazarev/numbers_and_words/pull/289)\] \([@dblock](https://github.com/dblock)\)
|
|
25
|
+
* Decline Russian and Ukrainian numbers by `case:`, with `animate:` accusatives ("двадцать первого", "двадцати одной тысячи"). \[[#296](https://github.com/kslazarev/numbers_and_words/pull/296), [#298](https://github.com/kslazarev/numbers_and_words/pull/298)\] \([@dblock](https://github.com/dblock)\)
|
|
26
|
+
* Add `unit:`, `subunit:` and `zero_subunit:` to spell amounts with units in the right plural form and gender ("двадцать один рубль", "twenty-one dollars and fifty cents"). \[[#299](https://github.com/kslazarev/numbers_and_words/pull/299), [#302](https://github.com/kslazarev/numbers_and_words/pull/302)\] \([@dblock](https://github.com/dblock)\)
|
|
27
|
+
* Use the standard locale codes `sv`, `uk` and `kk`, and deprecate `se`, `ua` and `kz`. \[[#300](https://github.com/kslazarev/numbers_and_words/pull/300)\] \([@dblock](https://github.com/dblock)\)
|
|
28
|
+
* Add experimental Azerbaijani (`az`), with decimals read as fractions ("üç tam yüzdə on dörd"), ordinals and `remove_zero`, from the digitaz and hydra-billing forks. \[[#308](https://github.com/kslazarev/numbers_and_words/pull/308)\] \([@stager94](https://github.com/stager94), [@NatalieKor](https://github.com/NatalieKor), [@flash-gordon](https://github.com/flash-gordon), [@dblock](https://github.com/dblock)\)
|
|
29
|
+
* Add numeral spelling and grammar references in a Sources section on every language page. \[[#316](https://github.com/kslazarev/numbers_and_words/pull/316)\] \([@dblock](https://github.com/dblock)\)
|
|
30
|
+
* Check spelled-out integers against the Unicode CLDR spell-out rules from twitter_cldr in every language CLDR covers, with every accepted difference reviewed as a rule in `spec/fixtures/cldr_rules.yml` or an exception in `spec/fixtures/cldr_exceptions.yml`. \[[#317](https://github.com/kslazarev/numbers_and_words/pull/317)\] \([@dblock](https://github.com/dblock)\)
|
|
31
|
+
* Release 1.1.0 instead of 2.0.0: keep the 1.0 defaults, error classes, locale codes and Ruby 3.1 support, warn about what 2.0 will change, and add `NumbersAndWords.config.strict_options` to raise for unsupported options. \[[#320](https://github.com/kslazarev/numbers_and_words/pull/320)\] \([@dblock](https://github.com/dblock)\)
|
|
32
|
+
|
|
33
|
+
### Bugs
|
|
34
|
+
* Fix Latin letters inside Cyrillic words in Russian, Ukrainian and Kazakh, and the Italian spelling of 17 (`diciassette`). \[[#216](https://github.com/kslazarev/numbers_and_words/pull/216)\]
|
|
35
|
+
* Fix Ukrainian separators using Latin letters and validate locale scripts, Unicode normalization and invisible characters. \[[#217](https://github.com/kslazarev/numbers_and_words/pull/217)\] \([@dblock](https://github.com/dblock)\)
|
|
36
|
+
* Fix fixture examples that never ran because of duplicate YAML keys, and fail on duplicate fixture keys. \[[#241](https://github.com/kslazarev/numbers_and_words/pull/241)\] \([@dblock](https://github.com/dblock)\)
|
|
37
|
+
* Fix French plural agreement of `cents` and `quatre-vingts` at the end of a number and before scale nouns (`deux-cents millions`). \[[#242](https://github.com/kslazarev/numbers_and_words/pull/242)\] \([@dblock](https://github.com/dblock)\)
|
|
38
|
+
* Accent Italian compounds ending in -tre (`ventitré`, `milletré`). \[[#243](https://github.com/kslazarev/numbers_and_words/pull/243)\] \([@dblock](https://github.com/dblock)\)
|
|
39
|
+
* Join a Brazilian Portuguese remainder below one hundred with `e` (`um bilhão e vinte e um`), and keep the scale word singular in compound fractions (`décimos de milésimo`). \[[#244](https://github.com/kslazarev/numbers_and_words/pull/244)\] \([@dblock](https://github.com/dblock)\)
|
|
40
|
+
* Use Ukrainian nominative plurals after 2-4 (`два мільйони`) and fix the missing quintillion translation. \[[#245](https://github.com/kslazarev/numbers_and_words/pull/245)\] \([@dblock](https://github.com/dblock)\)
|
|
41
|
+
* Fix `Translation missing` for 10^18 in Czech, German, Estonian, French, Swiss French, Lithuanian and Latvian, and test every scale word in every locale. \[[#246](https://github.com/kslazarev/numbers_and_words/pull/246)\] \([@dblock](https://github.com/dblock)\)
|
|
42
|
+
* Write Russian and Ukrainian compound fraction names as one word (`десятитысячных`), and fix the Ukrainian spelling of `тисячна`. \[[#247](https://github.com/kslazarev/numbers_and_words/pull/247)\] \([@dblock](https://github.com/dblock)\)
|
|
43
|
+
* Use `milijardas` for Lithuanian 10^9 and the short scale above it (`trilijonas` for 10^12). \[[#248](https://github.com/kslazarev/numbers_and_words/pull/248), [#289](https://github.com/kslazarev/numbers_and_words/pull/289)\] \([@dblock](https://github.com/dblock)\)
|
|
44
|
+
* Use the Estonian long scale (`biljon` for 10^12, `triljon` for 10^18). \[[#249](https://github.com/kslazarev/numbers_and_words/pull/249)\] \([@dblock](https://github.com/dblock)\)
|
|
45
|
+
* Join Danish hundreds and final tens or ones with `og` (`et hundrede og et`, `et tusinde og et`). \[[#250](https://github.com/kslazarev/numbers_and_words/pull/250)\] \([@dblock](https://github.com/dblock)\)
|
|
46
|
+
* Say `and` after hundreds in British English with `hundreds_with_union: true` (`one hundred and one`), which 2.0 will make the default; see UPGRADING.md. \[[#251](https://github.com/kslazarev/numbers_and_words/pull/251)\] \([@dblock](https://github.com/dblock)\)
|
|
47
|
+
* Read Dutch decimals as fractions joined with `en` (`eenentwintig en zevenenzeventig honderdsten`) instead of mixing `komma` with fraction words. \[[#252](https://github.com/kslazarev/numbers_and_words/pull/252)\] \([@dblock](https://github.com/dblock)\)
|
|
48
|
+
* Fix Czech decimal agreement (`jedna celá`, `dvě celé`, `třicet jedna setin`) and spell `milion` consistently with `bilion`. \[[#253](https://github.com/kslazarev/numbers_and_words/pull/253)\] \([@dblock](https://github.com/dblock)\)
|
|
49
|
+
* Expand scientific-notation floats before conversion instead of losing their exponent and fractional value. \[[#227](https://github.com/kslazarev/numbers_and_words/pull/227)\] \([@dblock](https://github.com/dblock)\)
|
|
50
|
+
* Fix Italian scale words: `un milione` and `un miliardo` instead of `uno milione`, and keep `mille` apart from a preceding scale word (`un milione mille`). \[[#230](https://github.com/kslazarev/numbers_and_words/pull/230)\] \([@dblock](https://github.com/dblock)\)
|
|
51
|
+
* Fix `NameError` when converting decimals in Portuguese (`pt`), with `remove_zero` support. \[[#233](https://github.com/kslazarev/numbers_and_words/pull/233)\] \([@dblock](https://github.com/dblock)\)
|
|
52
|
+
* Correct Swedish compounds, grammatical gender and long-scale singular/plural names, completing #150. \[[#225](https://github.com/kslazarev/numbers_and_words/pull/225)\] \([@Liggliluff](https://github.com/Liggliluff), [@dblock](https://github.com/dblock)\)
|
|
53
|
+
* Read English numbers of five or more digits normally with `pronounced: true` instead of dropping their leading digits. \[[#273](https://github.com/kslazarev/numbers_and_words/pull/273)\] \([@dblock](https://github.com/dblock)\)
|
|
54
|
+
* Use the usual forms reviewed in #255: Czech `sto`, `tisíc` and ordinal `tisící`, Danish `en` and `tusind`, Hungarian `száz`, `ezer` and `kétezer`, Italian `ventun milioni`, Kazakh `жүз` and `мың`, Armenian `հազար`, and Spanish feminine `una`. \[[#289](https://github.com/kslazarev/numbers_and_words/pull/289)\] \([@dblock](https://github.com/dblock)\)
|
|
55
|
+
* Use European Portuguese forms and the long scale in `pt` (`dezasseis`, `mil milhões`, `um bilião`), say `mil` instead of `um mil`, and join scale words with `e` (`um milhão e cem`); see UPGRADING.md. \[[#309](https://github.com/kslazarev/numbers_and_words/pull/309)\] \([@lomefin](https://github.com/lomefin), [@dblock](https://github.com/dblock)\)
|
|
56
|
+
* Put `de` (`di` in Italian, `d'` before a French vowel) between a unit and a number ending in a scale word of a million or more in Spanish, French, Italian and Portuguese (`um milhão de reais`, `un million d'euros`). \[[#310](https://github.com/kslazarev/numbers_and_words/pull/310)\] \([@dblock](https://github.com/dblock)\)
|
|
57
|
+
* Read negative numbers with the language's minus word (`minus five`, `âm bốn mươi hai`) instead of dropping the sign, raise `RangeError` past a language's largest scale word instead of printing a bare multiplier, raise `NumbersAndWords::UnsupportedNumberError` for decimals in languages without them and for negative ordinals, fix Russian septillions, and join Lithuanian and Latvian multipliers to round ordinals (`dutūkstantasis`, `divtūkstošais`, Latvian `simts`); see UPGRADING.md. \[[#311](https://github.com/kslazarev/numbers_and_words/pull/311)\] \([@dblock](https://github.com/dblock)\)
|
|
58
|
+
* Fix spelling found reviewing every language: British English `one thousand and one`, Dutch long-scale `quadriljoen` and `quintiljard`, Swedish `tjugoettusen`, Norwegian `hundre og ett tusen`, Georgian `ტრილიონი`, Hebrew `שלושת האלפים`, Brazilian Portuguese masculine scale nouns (`dois milhões`), `milionésimo` and decimals read as a number, Italian `centotto`, Romanian `al o miilea`, Vietnamese `mười tám`, Russian and Ukrainian `тысяча первый`, Czech counting forms (`dvacet dva`), Hungarian `két egész`, Spanish `primer`, `veinticinco` and `un euro`, and French `deux-millionième`; see UPGRADING.md. \[[#312](https://github.com/kslazarev/numbers_and_words/pull/312)\] \([@dblock](https://github.com/dblock)\)
|
|
59
|
+
* Fix units, long decimals and decimal ordinals across languages: the form of a number before a unit (`ein Euro`, `eine Mark`, `en krona`, `un euro`, `un leu`, `o liră`, `két forint`), European Portuguese `gender:` (`duas libras`), Hebrew and Arabic unit order and forms (`שקל אחד`, `ديناران`, `أحد عشر دينارًا`) with an Arabic plural rule, the word joining a subunit in Danish, Swedish, Norwegian, Finnish, Estonian and Georgian and attached in Hebrew and Arabic, Russian, Ukrainian and Czech decimals with 16 or more fractional digits, the cardinal form for decimals with `ordinal: true` in every language, one `RangeError` wording, Spanish ordinals of 10^27 and larger, Brazilian Portuguese `quintilionésimo` and `decilionésimo`, and Hindi, Bengali and Urdu ordinals of very large numbers; see UPGRADING.md. \[[#313](https://github.com/kslazarev/numbers_and_words/pull/313)\] \([@dblock](https://github.com/dblock)\)
|
|
60
|
+
* Correct Armenian `կվադրիլիոն`, Bulgarian `двехиляден`, Czech `nula celá`, Slovak `nula celých`, Danish neuter ordinal `andet`, Thai `หนึ่งล้านเอ็ด`, Georgian scale endings, Hungarian compound ordinals, Italian `tremilionitreesimo`, Spanish scale-ordinal prefixes, Russian and Ukrainian ninety-thousandths, and French `zéro euro`. Use consistent numeric Vietnamese decimals, Czech `biliontina`, Estonian `sada` and `tuhat`, German `millionste` and concise Russian and Ukrainian scale ordinals; clarify decimal and ordinal documentation, retain separated Dutch and Swedish million ordinals, and correct the Kuwaiti dinar's 1,000 fils. \[[#314](https://github.com/kslazarev/numbers_and_words/pull/314)\] \([@dblock](https://github.com/dblock)\)
|
|
61
|
+
* Drop the accent of Italian `tré` inside million and larger ordinals (`ventitremilionesimo`), and the leading `un` of compound ordinals (`milioneventitreesimo`). \[[#317](https://github.com/kslazarev/numbers_and_words/pull/317)\] \([@dblock](https://github.com/dblock)\)
|
|
5
62
|
|
|
6
63
|
## 1.0.3 (Dec 23, 2025)
|
|
7
64
|
|
data/README.md
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
<img src="assets/logo.svg" alt="A red 42 tile speaking through a speech bubble that holds the Ruby string "forty-two", followed by .to_words." width="160">
|
|
2
|
+
|
|
3
|
+
# numbers_and_words
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/rb/numbers_and_words)
|
|
6
|
+
[](https://github.com/kslazarev/numbers_and_words/actions/workflows/test.yml)
|
|
7
|
+
[](https://github.com/kslazarev/numbers_and_words/actions/workflows/lint.yml)
|
|
8
|
+
[](https://github.com/kslazarev/numbers_and_words/actions/workflows/package.yml)
|
|
9
|
+
[](https://coveralls.io/github/kslazarev/numbers_and_words?branch=master)
|
|
10
|
+
|
|
11
|
+
Spell out numbers in several languages using the I18n gem.
|
|
12
|
+
|
|
13
|
+
Перевод чисел в слова при помощи библиотеки I18n.
|
|
14
|
+
|
|
15
|
+
Convertit les nombres en lettres en utilisant la librairie I18n.
|
|
16
|
+
|
|
17
|
+
Számok betűvel írva az I18n könyvtár segítségével.
|
|
18
|
+
|
|
19
|
+
I18n kütüphanesi ile sayıları yazıya çevirir.
|
|
20
|
+
|
|
21
|
+
Soletra números em vários idiomas utilizando a biblioteca I18n.
|
|
22
|
+
|
|
23
|
+
Deletrea números en varios idiomas utilizando la gema I18n.
|
|
24
|
+
|
|
25
|
+
## Installation / Установка / Installation
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
gem install numbers_and_words
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or add it to your Gemfile:
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
gem 'numbers_and_words'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage / Использование / Utilisation
|
|
38
|
+
|
|
39
|
+
Call `to_words` on an integer, a float or an array in the locale of your choice.
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
require 'numbers_and_words'
|
|
43
|
+
|
|
44
|
+
I18n.with_locale(:en) { 42.to_words }
|
|
45
|
+
# => "forty-two"
|
|
46
|
+
|
|
47
|
+
I18n.with_locale(:es) { 42.to_words }
|
|
48
|
+
# => "cuarenta y dos"
|
|
49
|
+
|
|
50
|
+
I18n.with_locale(:ru) { 42.to_words }
|
|
51
|
+
# => "сорок два"
|
|
52
|
+
|
|
53
|
+
I18n.with_locale(:fr) { 42.to_words }
|
|
54
|
+
# => "quarante-deux"
|
|
55
|
+
|
|
56
|
+
I18n.with_locale(:de) { 42.to_words }
|
|
57
|
+
# => "zweiundvierzig"
|
|
58
|
+
|
|
59
|
+
I18n.with_locale(:en) { [1, 2, 3].to_words }
|
|
60
|
+
# => ["one", "two", "three"]
|
|
61
|
+
|
|
62
|
+
I18n.with_locale(:en) { 21.77.to_words }
|
|
63
|
+
# => "twenty-one and seventy-seven hundredths"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Floats that Ruby prints in scientific notation, such as `0.00001` (`1.0e-05`), are converted from their exact decimal value.
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
I18n.with_locale(:en) { 0.00001.to_words }
|
|
70
|
+
# => "zero and one hundred-thousandth"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Negative numbers start with the language's word for minus. They have no ordinal, so `ordinal: true` raises `NumbersAndWords::UnsupportedNumberError`, an `ArgumentError`, which is also raised for decimals in a language without decimals. Numbers beyond a language's largest scale word raise `RangeError`; each language page gives its limit.
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
I18n.with_locale(:en) { -42.to_words }
|
|
77
|
+
# => "minus forty-two"
|
|
78
|
+
|
|
79
|
+
I18n.with_locale(:fr) { -1.5.to_words }
|
|
80
|
+
# => "moins un et cinq dixièmes"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Command Line
|
|
84
|
+
|
|
85
|
+
The `to_words` command spells out each argument, or each number read from standard input, one per line.
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
$ to_words 42 1.5
|
|
89
|
+
forty-two
|
|
90
|
+
one and five tenths
|
|
91
|
+
|
|
92
|
+
$ to_words --locale ru 2000
|
|
93
|
+
две тысячи
|
|
94
|
+
|
|
95
|
+
$ echo 21 | to_words --ordinal
|
|
96
|
+
twenty-first
|
|
97
|
+
|
|
98
|
+
$ to_words --locale es --gender female 21
|
|
99
|
+
veintiuna
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Choose the language with `-l`/`--locale` (default `en`). Every `to_words` option has a flag, such as `--ordinal` (with a `--no-` form), `--gender VALUE` or `--precision N`; `to_words --help` lists them with the languages that support each. Errors go to standard error with exit status 1.
|
|
103
|
+
|
|
104
|
+
## Supported Languages / Языки / Langues Supportées
|
|
105
|
+
|
|
106
|
+
Each language page has examples, says whether decimals are supported, and documents every option the language accepts.
|
|
107
|
+
|
|
108
|
+
| Language | Name | Code |
|
|
109
|
+
| --- | --- | --- |
|
|
110
|
+
| [Arabic](docs/languages/ar.md)* | العربية | `ar` |
|
|
111
|
+
| [Armenian](docs/languages/hy.md) | Հայերեն | `hy` |
|
|
112
|
+
| [Azerbaijani](docs/languages/az.md)* | Azərbaycan dili | `az` |
|
|
113
|
+
| [Bengali](docs/languages/bn.md)* | বাংলা | `bn` |
|
|
114
|
+
| [Brazilian Portuguese](docs/languages/pt-BR.md) | Português brasileiro | `pt-BR` |
|
|
115
|
+
| [British English](docs/languages/en-GB.md) | English (British) | `en-GB` |
|
|
116
|
+
| [Bulgarian](docs/languages/bg.md)* | Български | `bg` |
|
|
117
|
+
| [Chinese](docs/languages/zh.md)* | 中文 | `zh` |
|
|
118
|
+
| [Czech](docs/languages/cs.md) | Čeština | `cs` |
|
|
119
|
+
| [Danish](docs/languages/da.md) | Dansk | `da` |
|
|
120
|
+
| [Dutch](docs/languages/nl.md) | Nederlands | `nl` |
|
|
121
|
+
| [English](docs/languages/en.md) | English | `en` |
|
|
122
|
+
| [Estonian](docs/languages/et.md) | Eesti | `et` |
|
|
123
|
+
| [Finnish](docs/languages/fi.md)* | Suomi | `fi` |
|
|
124
|
+
| [French](docs/languages/fr.md) | Français | `fr` |
|
|
125
|
+
| [Georgian](docs/languages/ka.md) | ქართული | `ka` |
|
|
126
|
+
| [German](docs/languages/de.md) | Deutsch | `de` |
|
|
127
|
+
| [Greek](docs/languages/el.md)* | Ελληνικά | `el` |
|
|
128
|
+
| [Hebrew](docs/languages/he.md)* | עברית | `he` |
|
|
129
|
+
| [Hindi](docs/languages/hi.md)* | हिन्दी | `hi` |
|
|
130
|
+
| [Hungarian](docs/languages/hu.md) | Magyar | `hu` |
|
|
131
|
+
| [Indonesian](docs/languages/id.md) | Bahasa Indonesia | `id` |
|
|
132
|
+
| [Italian](docs/languages/it.md) | Italiano | `it` |
|
|
133
|
+
| [Japanese](docs/languages/ja.md)* | 日本語 | `ja` |
|
|
134
|
+
| [Kazakh](docs/languages/kk.md) | Қазақша | `kk` |
|
|
135
|
+
| [Korean](docs/languages/ko.md)* | 한국어 | `ko` |
|
|
136
|
+
| [Latvian](docs/languages/lv.md) | Latviešu | `lv` |
|
|
137
|
+
| [Lithuanian](docs/languages/lt.md) | Lietuvių | `lt` |
|
|
138
|
+
| [Malay](docs/languages/ms.md)* | Bahasa Melayu | `ms` |
|
|
139
|
+
| [Norwegian Bokmål](docs/languages/nb.md)* | Norsk bokmål | `nb` |
|
|
140
|
+
| [Polish](docs/languages/pl.md)* | Polski | `pl` |
|
|
141
|
+
| [Portuguese](docs/languages/pt.md) | Português | `pt` |
|
|
142
|
+
| [Romanian](docs/languages/ro.md)* | Română | `ro` |
|
|
143
|
+
| [Russian](docs/languages/ru.md) | Русский | `ru` |
|
|
144
|
+
| [Slovak](docs/languages/sk.md)* | Slovenčina | `sk` |
|
|
145
|
+
| [Spanish](docs/languages/es.md) | Español | `es` |
|
|
146
|
+
| [Swedish](docs/languages/sv.md)* | Svenska | `sv` |
|
|
147
|
+
| [Swiss French](docs/languages/fr-CH.md) | Français (Suisse) | `fr-CH` |
|
|
148
|
+
| [Thai](docs/languages/th.md)* | ภาษาไทย | `th` |
|
|
149
|
+
| [Turkish](docs/languages/tr.md) | Türkçe | `tr` |
|
|
150
|
+
| [Ukrainian](docs/languages/uk.md) | Українська | `uk` |
|
|
151
|
+
| [Urdu](docs/languages/ur.md)* | اردو | `ur` |
|
|
152
|
+
| [Vietnamese](docs/languages/vi.md) | Tiếng Việt | `vi` |
|
|
153
|
+
|
|
154
|
+
\* Experimental: known gaps, or no native-speaker review yet; its page says why. See [#255](https://github.com/kslazarev/numbers_and_words/issues/255) to help.
|
|
155
|
+
|
|
156
|
+
Regional locales use their language: `en-AU`, `en-CA`, `en-IN` and `en-US` use `en`; `fr-CA` uses `fr`; `de-AT` and `de-CH` use `de`; `it-CH` uses `it`; `nb-NO`, `no` and `no-NO` use `nb`; `zh-CN` and `zh-SG` use `zh`.
|
|
157
|
+
|
|
158
|
+
## Options / Опции / Options
|
|
159
|
+
|
|
160
|
+
Options are passed to `to_words`. Language-specific options, such as `gender`, `ordinal` or `remove_zero`, are described on each language page.
|
|
161
|
+
|
|
162
|
+
### Precision
|
|
163
|
+
|
|
164
|
+
`precision` pads the fractional part of a float with zeros.
|
|
165
|
+
|
|
166
|
+
```ruby
|
|
167
|
+
I18n.with_locale(:ru) { 0.1.to_words(precision: 3) }
|
|
168
|
+
# => "ноль целых и сто тысячных"
|
|
169
|
+
|
|
170
|
+
I18n.with_locale(:es) { 0.2.to_words(precision: 2) }
|
|
171
|
+
# => "cero con veinte centésimas"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Micro Separator
|
|
175
|
+
|
|
176
|
+
`micro_separator` replaces the word between the integral and fractional parts of a float.
|
|
177
|
+
|
|
178
|
+
```ruby
|
|
179
|
+
I18n.with_locale(:en) { 21.77.to_words(micro_separator: "plus") }
|
|
180
|
+
# => "twenty-one plus seventy-seven hundredths"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Fallback
|
|
184
|
+
|
|
185
|
+
`fallback` decides what happens when the current locale has no bundled rules or the configuration disables it. By default this raises `NumbersAndWords::UnsupportedLanguageError`. Set it to a bundled locale to convert in that locale, or to `true` to return the digits.
|
|
186
|
+
|
|
187
|
+
```ruby
|
|
188
|
+
I18n.with_locale(:am) { 42.to_words(fallback: :fr) }
|
|
189
|
+
# => "quarante-deux"
|
|
190
|
+
|
|
191
|
+
I18n.with_locale(:am) { 42.to_words(fallback: true) }
|
|
192
|
+
# => "42"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Other options are validated for the fallback locale. `I18n.with_locale` raises `I18n::InvalidLocale` for a locale missing from `I18n.available_locales` before the gem is called. To set a fallback for every call, see [Configuration](#configuration--конфигурация).
|
|
196
|
+
|
|
197
|
+
### Unit
|
|
198
|
+
|
|
199
|
+
`unit` follows a number with a unit word, such as a currency, in the form the number takes. The gem ships no units: `unit: :ruble` looks up `units.ruble` in your application's translations for the current locale, and a dotted key such as `"money.ruble"` looks up `units.money.ruble`. A unit has one form per plural category of the language, chosen with the gem's plural rules (`one`, `few`, `many` and `other` in Russian and Ukrainian, `one` and `other` in English), or a single string for a unit that never changes. An optional `gender` sets the gender of the number in languages with a `gender` option; a `gender` passed to `to_words` overrides it.
|
|
200
|
+
|
|
201
|
+
```yaml
|
|
202
|
+
en:
|
|
203
|
+
units:
|
|
204
|
+
dollar: { one: dollar, other: dollars }
|
|
205
|
+
cent: { one: cent, other: cents }
|
|
206
|
+
fr:
|
|
207
|
+
units:
|
|
208
|
+
euro: { one: euro, other: euros }
|
|
209
|
+
centime: { one: centime, other: centimes }
|
|
210
|
+
ru:
|
|
211
|
+
units:
|
|
212
|
+
ruble: { one: рубль, few: рубля, many: рублей, other: рубля, gender: male }
|
|
213
|
+
kopeck: { one: копейка, few: копейки, many: копеек, other: копейки, gender: female }
|
|
214
|
+
zh:
|
|
215
|
+
units:
|
|
216
|
+
yuan: 元
|
|
217
|
+
he:
|
|
218
|
+
units:
|
|
219
|
+
shekel: { one: שקל, other: שקלים, gender: male }
|
|
220
|
+
agora: { one: אגורה, other: אגורות, gender: female }
|
|
221
|
+
ar:
|
|
222
|
+
units:
|
|
223
|
+
dinar: { zero: دينار, one: دينار, two: ديناران, few: دنانير, many: دينارًا, other: دينار }
|
|
224
|
+
fils: { one: فلس, two: فلسان, few: فلوس, many: فلسًا, other: فلس }
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
With these translations:
|
|
228
|
+
|
|
229
|
+
```ruby
|
|
230
|
+
I18n.with_locale(:en) { 1.to_words(unit: :dollar) }
|
|
231
|
+
# => "one dollar"
|
|
232
|
+
|
|
233
|
+
I18n.with_locale(:en) { 21.to_words(unit: :dollar) }
|
|
234
|
+
# => "twenty-one dollars"
|
|
235
|
+
|
|
236
|
+
I18n.with_locale(:ru) { 21.to_words(unit: :ruble) }
|
|
237
|
+
# => "двадцать один рубль"
|
|
238
|
+
|
|
239
|
+
I18n.with_locale(:ru) { 22.to_words(unit: :kopeck) }
|
|
240
|
+
# => "двадцать две копейки"
|
|
241
|
+
|
|
242
|
+
I18n.with_locale(:ru) { 11.to_words(unit: :kopeck) }
|
|
243
|
+
# => "одиннадцать копеек"
|
|
244
|
+
|
|
245
|
+
I18n.with_locale(:ru) { [1, 5].to_words(unit: :ruble) }
|
|
246
|
+
# => ["один рубль", "пять рублей"]
|
|
247
|
+
|
|
248
|
+
I18n.with_locale(:zh) { 21.to_words(unit: :yuan) }
|
|
249
|
+
# => "二十一元"
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
The unit follows the number after a space, or directly in languages written without spaces (Chinese, Japanese and Thai). Hebrew and Arabic put one after its unit, and Arabic says two with the unit's dual form alone, as their language pages describe. Before a unit, a number takes the form a language uses before a noun, which its locale file lists under `numbers.before_unit`: German "ein Euro" and "eine Mark", Swedish "en krona", Italian "un euro", Romanian "un leu" and "o liră", Hungarian "két forint", Spanish "un euro" (see `apocopated` on its page). The unit's `gender` chooses between the forms where they differ. With `ordinal: true` the unit takes its singular (`one`) form, because an ordinal names one item: the twenty-first dollar. Decimals keep their cardinal form with `ordinal: true`.
|
|
253
|
+
|
|
254
|
+
```ruby
|
|
255
|
+
I18n.with_locale(:en) { 21.to_words(unit: :dollar, ordinal: true) }
|
|
256
|
+
# => "twenty-first dollar"
|
|
257
|
+
|
|
258
|
+
I18n.with_locale(:ru) { 22.to_words(unit: :kopeck, ordinal: true) }
|
|
259
|
+
# => "двадцать вторая копейка"
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
A unit without a translation, or without the form a number needs and no `other` form, raises `NumbersAndWords::UnsupportedOptionError`, for example `unit :euro has no translation for locale :ru (expected units.euro)`. Unit forms are nominative, so `unit` with a `case` other than `:nominative` raises too.
|
|
263
|
+
|
|
264
|
+
In Spanish, French, Italian and Portuguese, a whole number that ends in a scale word of a million or more takes a preposition before the unit (`de`, or `di` in Italian), but one that ends in another word, such as `mil`, does not. French elides `de` to `d'` before a unit that starts with a vowel; a unit sets `elision: true` for a mute h (`d'hectares`) or `elision: false` for another exception. Romanian puts `de` in the unit forms, as it does for any number from 20.
|
|
265
|
+
|
|
266
|
+
```ruby
|
|
267
|
+
I18n.with_locale(:fr) { 2_000_000.to_words(unit: :euro) }
|
|
268
|
+
# => "deux millions d'euros"
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
After a decimal, the unit takes its `other` form, which is the genitive singular in Russian and Czech; in French and Portuguese, amounts below 2 take the singular, and in Romanian the unit takes its `few` form. A float with no fractional part reads as a whole number.
|
|
272
|
+
|
|
273
|
+
```ruby
|
|
274
|
+
I18n.with_locale(:en) { 1.5.to_words(unit: :dollar) }
|
|
275
|
+
# => "one point five dollars"
|
|
276
|
+
|
|
277
|
+
I18n.with_locale(:ru) { 1.5.to_words(unit: :ruble) }
|
|
278
|
+
# => "одна целая и пять десятых рубля"
|
|
279
|
+
|
|
280
|
+
I18n.with_locale(:fr) { 1.5.to_words(unit: :euro) }
|
|
281
|
+
# => "un virgule cinq euro"
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
`subunit` spells an amount in two units, such as dollars and cents: the decimal places become the subunit, rounded half to even. `precision` sets how many decimal places make one subunit, 2 by default. A zero subunit is left out unless `zero_subunit: true`, and a zero unit is left out with `remove_zero: true` in languages that support it. The two parts are joined with the language's word for it (`and` in English, `et` in French), attached to the subunit in Hebrew and Arabic (`ו`, `و`), or a space.
|
|
285
|
+
|
|
286
|
+
```ruby
|
|
287
|
+
I18n.with_locale(:en) { 21.5.to_words(unit: :dollar, subunit: :cent) }
|
|
288
|
+
# => "twenty-one dollars and fifty cents"
|
|
289
|
+
|
|
290
|
+
I18n.with_locale(:ru) { 22.22.to_words(unit: :ruble, subunit: :kopeck) }
|
|
291
|
+
# => "двадцать два рубля двадцать две копейки"
|
|
292
|
+
|
|
293
|
+
I18n.with_locale(:fr) { 21.01.to_words(unit: :euro, subunit: :centime) }
|
|
294
|
+
# => "vingt et un euros et un centime"
|
|
295
|
+
|
|
296
|
+
I18n.with_locale(:en) { 21.to_words(unit: :dollar, subunit: :cent, zero_subunit: true) }
|
|
297
|
+
# => "twenty-one dollars and zero cents"
|
|
298
|
+
|
|
299
|
+
I18n.with_locale(:en) { 0.5.to_words(unit: :dollar, subunit: :cent, remove_zero: true) }
|
|
300
|
+
# => "fifty cents"
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
`subunit` without `unit`, or with `ordinal: true`, raises `NumbersAndWords::UnsupportedOptionError`, and so does `zero_subunit` without `subunit`.
|
|
304
|
+
|
|
305
|
+
### Unsupported Options
|
|
306
|
+
|
|
307
|
+
Every language accepts `precision`, `micro_separator`, `fallback`, `unit`, `subunit` and `zero_subunit`, plus the options on its language page. Any other option or value is ignored with a warning that names the supported alternatives, and 2.0 will raise `NumbersAndWords::UnsupportedOptionError`, an `ArgumentError`, instead; set [`strict_options`](#configuration--конфигурация) to `true` to raise now.
|
|
308
|
+
|
|
309
|
+
Vietnamese has no grammatical gender, so `21.to_words(gender: :female)` in `vi` returns "hai mươi mốt" and warns once:
|
|
310
|
+
|
|
311
|
+
```
|
|
312
|
+
numbers_and_words: unsupported option :gender for locale :vi; supported: :micro_separator, :ordinal, :precision, :remove_zero, :subunit, :unit, :zero_subunit; ignored, set NumbersAndWords.config.strict_options = true to raise, the default in 2.0
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Deprecations
|
|
316
|
+
|
|
317
|
+
The defaults `fraction: true` in English, French, Italian and Portuguese, `spelling: :traditional` in French and `hundreds_with_union: false` in British English are deprecated and will change in 2.0; pass the option explicitly to keep or change the reading. The locale codes `se`, `ua` and `kz` are deprecated in favor of `sv`, `uk` and `kk`. Each deprecation warns once per process; warnings about defaults are Ruby deprecation warnings, shown with `Warning[:deprecated] = true` or `ruby -W:deprecated`. See [UPGRADING](UPGRADING.md).
|
|
318
|
+
|
|
319
|
+
## Configuration / Конфигурация
|
|
320
|
+
|
|
321
|
+
All bundled locales are loaded by default. To load only some, configure the gem after requiring it:
|
|
322
|
+
|
|
323
|
+
```ruby
|
|
324
|
+
NumbersAndWords.configure do |config|
|
|
325
|
+
config.locales = [:en, :ru]
|
|
326
|
+
end
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Or set it directly:
|
|
330
|
+
|
|
331
|
+
```ruby
|
|
332
|
+
NumbersAndWords.config.locales = [:en, :ru]
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Regional locales such as `"en-US"` are normalized to their bundled locale. `nil` restores all bundled locales and `[]` loads none. An unsupported locale raises `ArgumentError` and changes nothing. A direct assignment takes effect immediately; a `configure` block takes effect when it completes, and not at all if it raises.
|
|
336
|
+
|
|
337
|
+
`fallback` sets the default [fallback](#fallback); the `fallback` option of `to_words` overrides it.
|
|
338
|
+
|
|
339
|
+
```ruby
|
|
340
|
+
NumbersAndWords.config.fallback = :en
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
`strict_options` (`false` by default) ignores an unsupported option or value with a warning; `true` raises `NumbersAndWords::UnsupportedOptionError` instead, which 2.0 will make the default.
|
|
344
|
+
|
|
345
|
+
```ruby
|
|
346
|
+
NumbersAndWords.config.strict_options = true
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
Configuration changes only this gem's locale files in `I18n.load_path` and its pluralization rules; application translations and an explicitly assigned `I18n.available_locales` are kept. Converting in a disabled locale raises `NumbersAndWords::UnsupportedLanguageError` (`Language not configured`) unless a fallback is set.
|
|
351
|
+
|
|
352
|
+
Require the gem before looking up any translations, as Rails does, and configure it during application initialization. Configuring reloads the I18n backend, as assigning `I18n.load_path` does, so store runtime-only translations afterwards. Configuring again doesn't duplicate load paths. The gem never changes `I18n.locale` or `I18n.default_locale`, so don't disable the locales they use.
|
|
353
|
+
|
|
354
|
+
## Requirements / Требования / Configuration Requise
|
|
355
|
+
|
|
356
|
+
* Ruby 3.1 or later, including JRuby.
|
|
357
|
+
* I18n, tested with 1.6 and later.
|
|
358
|
+
|
|
359
|
+
## Upgrading / Обновление / Mise à jour
|
|
360
|
+
|
|
361
|
+
See [UPGRADING](UPGRADING.md) for changes in behavior, and for what 2.0 will change.
|
|
362
|
+
|
|
363
|
+
## Contributing / Участие / Contribuer
|
|
364
|
+
|
|
365
|
+
See [CONTRIBUTING](CONTRIBUTING.md), [AGENTS](AGENTS.md), [CHANGELOG](CHANGELOG.md), [UPGRADING](UPGRADING.md), [BENCHMARKS](BENCHMARKS.md) and [RELEASING](RELEASING.md).
|
|
366
|
+
|
|
367
|
+
## License / Лицензия / Licence
|
|
368
|
+
|
|
369
|
+
MIT License, see [LICENSE](LICENSE.txt).
|
data/bin/to_words
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'optparse'
|
|
4
|
+
require 'numbers_and_words'
|
|
5
|
+
|
|
6
|
+
module NumbersAndWords
|
|
7
|
+
# The to_words command: spells out numbers, one result per line.
|
|
8
|
+
class CLI
|
|
9
|
+
class Error < StandardError; end
|
|
10
|
+
|
|
11
|
+
DESCRIPTIONS = {
|
|
12
|
+
animate: 'Use the animate accusative, e.g. Russian "первого"',
|
|
13
|
+
apocopated: 'Use the shortened form, e.g. Spanish "un"',
|
|
14
|
+
case: 'Grammatical case, e.g. genitive or dative',
|
|
15
|
+
fraction: 'Read decimals as a fraction, e.g. "one and five tenths"',
|
|
16
|
+
gender: 'Grammatical gender, e.g. male, female, neuter or common',
|
|
17
|
+
hundreds_with_union: 'Say "and" after hundreds',
|
|
18
|
+
micro_separator: 'Word between the integral and fractional parts',
|
|
19
|
+
ordinal: 'Spell ordinal numbers',
|
|
20
|
+
precision: 'Pad the fractional part to N digits',
|
|
21
|
+
pronounced: 'Read four-digit numbers as they are spoken',
|
|
22
|
+
remove_hyphen: 'Remove the hyphen between tens and ones',
|
|
23
|
+
remove_zero: 'Omit a zero integral part',
|
|
24
|
+
script: 'Writing system, e.g. Japanese kanji or kana',
|
|
25
|
+
spelling: 'Spelling, e.g. French reformed (1990) or traditional',
|
|
26
|
+
tens_of_hundreds: 'Read thousands as tens of hundreds',
|
|
27
|
+
subunit: 'Spell the decimal places as a second unit, e.g. cents, under units.VALUE',
|
|
28
|
+
unit: 'Append a unit translated by the application under units.VALUE',
|
|
29
|
+
zero_subunit: 'Spell a zero subunit, e.g. "zero cents"'
|
|
30
|
+
}.freeze
|
|
31
|
+
|
|
32
|
+
def self.start(argv = ARGV, stdin: $stdin, stdout: $stdout, stderr: $stderr)
|
|
33
|
+
new(stdin:, stdout:, stderr:).run(argv)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Every option any bundled language accepts: name => [check, locales accepting it].
|
|
37
|
+
def self.options
|
|
38
|
+
@options ||= I18n.languages.sort.each_with_object({}) do |locale, table|
|
|
39
|
+
OptionsValidation.supported_options(locale).each { |name, check| (table[name] ||= [check, []])[1] << locale }
|
|
40
|
+
end.sort.to_h
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def initialize(stdin: $stdin, stdout: $stdout, stderr: $stderr)
|
|
44
|
+
@stdin = stdin
|
|
45
|
+
@stdout = stdout
|
|
46
|
+
@stderr = stderr
|
|
47
|
+
@locale = :en
|
|
48
|
+
@options = {}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def run(argv)
|
|
52
|
+
arguments = parser.parse(argv)
|
|
53
|
+
return 0 if @done
|
|
54
|
+
|
|
55
|
+
numbers = read_numbers(arguments)
|
|
56
|
+
@stdout.puts(::I18n.with_locale(@locale) { numbers.map { |number| number.to_words(@options) } })
|
|
57
|
+
0
|
|
58
|
+
rescue Error, OptionParser::ParseError, ArgumentError => e
|
|
59
|
+
# ArgumentError covers NumbersAndWords::UnsupportedOptionError and invalid I18n locales.
|
|
60
|
+
@stderr.puts "to_words: #{e.message}", parser.banner
|
|
61
|
+
1
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
def parser
|
|
67
|
+
@parser ||= OptionParser.new do |opts|
|
|
68
|
+
opts.banner = 'Usage: to_words [options] [NUMBER...]'
|
|
69
|
+
opts.separator ''
|
|
70
|
+
opts.separator 'Spells out each NUMBER, or whitespace-separated numbers read from standard input.'
|
|
71
|
+
opts.separator ''
|
|
72
|
+
opts.on('-l', '--locale LOCALE', 'Locale to spell numbers in (default: en)') { |value| @locale = value.to_sym }
|
|
73
|
+
define_conversion_options(opts)
|
|
74
|
+
define_informational_options(opts)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def define_informational_options(opts)
|
|
79
|
+
opts.separator ''
|
|
80
|
+
opts.on('-v', '--version', 'Show version') { finish(NumbersAndWords::VERSION) }
|
|
81
|
+
opts.on('-h', '--help', 'Show this help') { finish(opts.help) }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def finish(message)
|
|
85
|
+
@stdout.puts message
|
|
86
|
+
@done = true
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def read_numbers(arguments)
|
|
90
|
+
numbers = arguments.empty? ? @stdin.read.split : arguments
|
|
91
|
+
raise Error, 'no numbers given' if numbers.empty?
|
|
92
|
+
|
|
93
|
+
numbers.map { |number| parse_number(number) }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# One flag per to_words option known to any language; to_words validates
|
|
97
|
+
# each option for the selected language.
|
|
98
|
+
def define_conversion_options(opts)
|
|
99
|
+
opts.separator ''
|
|
100
|
+
opts.separator 'Options, each supported by the languages listed (validated for the selected locale):'
|
|
101
|
+
self.class.options.each do |name, (check, locales)|
|
|
102
|
+
opts.on(*flag(name, check), description(name, locales)) { |value| @options[name] = value }
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def flag(name, check)
|
|
107
|
+
flag = name.to_s.tr('_', '-')
|
|
108
|
+
case check
|
|
109
|
+
when OptionsValidation::BOOLEAN then ["--[no-]#{flag}"]
|
|
110
|
+
when OptionsValidation::GLOBAL[:precision] then ["--#{flag} N", Integer]
|
|
111
|
+
else ["--#{flag} VALUE"]
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def description(name, locales)
|
|
116
|
+
languages = locales.size == I18n.languages.size ? 'all' : locales.join(', ')
|
|
117
|
+
"#{DESCRIPTIONS.fetch(name) { name.to_s.tr('_', ' ').capitalize }} (#{languages})"
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def parse_number(text)
|
|
121
|
+
return Integer(text, 10) if /\A[+-]?\d+\z/.match?(text)
|
|
122
|
+
return Float(text) if /\A[+-]?\d+\.\d+\z/.match?(text)
|
|
123
|
+
|
|
124
|
+
raise Error, "not a number: #{text.inspect}"
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|