numbers_and_words 0.11.2 → 0.11.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +5 -5
  2. data/README.rdoc +23 -5
  3. data/lib/numbers_and_words.rb +2 -0
  4. data/lib/numbers_and_words/core_ext.rb +2 -0
  5. data/lib/numbers_and_words/core_ext/array.rb +2 -0
  6. data/lib/numbers_and_words/core_ext/float.rb +2 -0
  7. data/lib/numbers_and_words/core_ext/integer.rb +2 -0
  8. data/lib/numbers_and_words/helper_classes.rb +2 -0
  9. data/lib/numbers_and_words/helper_classes/array_extensions/helpers.rb +6 -4
  10. data/lib/numbers_and_words/helper_classes/figures_array.rb +2 -0
  11. data/lib/numbers_and_words/helper_classes/words_array.rb +2 -0
  12. data/lib/numbers_and_words/i18n.rb +2 -0
  13. data/lib/numbers_and_words/i18n/initialization.rb +2 -0
  14. data/lib/numbers_and_words/i18n/locales/numbers.cs.yml +37 -26
  15. data/lib/numbers_and_words/i18n/locales/numbers.de.yml +5 -4
  16. data/lib/numbers_and_words/i18n/locales/numbers.en-GB.yml +24 -8
  17. data/lib/numbers_and_words/i18n/locales/numbers.en.yml +10 -6
  18. data/lib/numbers_and_words/i18n/locales/numbers.es.yml +6 -5
  19. data/lib/numbers_and_words/i18n/locales/numbers.et.yml +4 -4
  20. data/lib/numbers_and_words/i18n/locales/numbers.fr.yml +45 -41
  21. data/lib/numbers_and_words/i18n/locales/numbers.hu.yml +11 -7
  22. data/lib/numbers_and_words/i18n/locales/numbers.hy.yml +7 -0
  23. data/lib/numbers_and_words/i18n/locales/numbers.it.yml +3 -3
  24. data/lib/numbers_and_words/i18n/locales/numbers.ka.yml +6 -14
  25. data/lib/numbers_and_words/i18n/locales/numbers.lt.yml +4 -5
  26. data/lib/numbers_and_words/i18n/locales/numbers.lv.yml +4 -5
  27. data/lib/numbers_and_words/i18n/locales/numbers.nl.yml +4 -3
  28. data/lib/numbers_and_words/i18n/locales/numbers.pt-BR.yml +51 -22
  29. data/lib/numbers_and_words/i18n/locales/numbers.pt.yml +21 -8
  30. data/lib/numbers_and_words/i18n/locales/numbers.ru.yml +39 -27
  31. data/lib/numbers_and_words/i18n/locales/numbers.se.yml +3 -3
  32. data/lib/numbers_and_words/i18n/locales/numbers.tr.yml +3 -3
  33. data/lib/numbers_and_words/i18n/locales/numbers.ua.yml +39 -15
  34. data/lib/numbers_and_words/i18n/locales/numbers.vi.yml +13 -0
  35. data/lib/numbers_and_words/i18n/pluralization.rb +3 -1
  36. data/lib/numbers_and_words/i18n/plurals/cs.rb +15 -10
  37. data/lib/numbers_and_words/i18n/plurals/fr.rb +5 -3
  38. data/lib/numbers_and_words/i18n/plurals/lt.rb +10 -7
  39. data/lib/numbers_and_words/i18n/plurals/lv.rb +5 -3
  40. data/lib/numbers_and_words/i18n/plurals/plurals.rb +2 -0
  41. data/lib/numbers_and_words/i18n/plurals/ru.rb +15 -10
  42. data/lib/numbers_and_words/i18n/plurals/ua.rb +2 -0
  43. data/lib/numbers_and_words/strategies.rb +2 -0
  44. data/lib/numbers_and_words/strategies/array_joiner.rb +2 -0
  45. data/lib/numbers_and_words/strategies/array_joiner/languages.rb +3 -0
  46. data/lib/numbers_and_words/strategies/array_joiner/languages/base.rb +2 -0
  47. data/lib/numbers_and_words/strategies/array_joiner/languages/cs.rb +2 -0
  48. data/lib/numbers_and_words/strategies/array_joiner/languages/en-GB.rb +3 -1
  49. data/lib/numbers_and_words/strategies/array_joiner/languages/en.rb +2 -0
  50. data/lib/numbers_and_words/strategies/array_joiner/languages/es.rb +2 -0
  51. data/lib/numbers_and_words/strategies/array_joiner/languages/families/base.rb +5 -3
  52. data/lib/numbers_and_words/strategies/array_joiner/languages/fr.rb +2 -0
  53. data/lib/numbers_and_words/strategies/array_joiner/languages/hu.rb +2 -0
  54. data/lib/numbers_and_words/strategies/array_joiner/languages/pt-BR.rb +2 -0
  55. data/lib/numbers_and_words/strategies/array_joiner/languages/ru.rb +2 -0
  56. data/lib/numbers_and_words/strategies/array_joiner/languages/ua.rb +2 -0
  57. data/lib/numbers_and_words/strategies/array_joiner/languages/vi.rb +12 -0
  58. data/lib/numbers_and_words/strategies/figures_converter.rb +2 -0
  59. data/lib/numbers_and_words/strategies/figures_converter/decorators.rb +3 -0
  60. data/lib/numbers_and_words/strategies/figures_converter/decorators/base.rb +2 -0
  61. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs.rb +2 -0
  62. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/base.rb +2 -0
  63. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/fractional.rb +2 -0
  64. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/integral.rb +3 -0
  65. data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB.rb +2 -0
  66. data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/base.rb +2 -0
  67. data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/fractional.rb +2 -0
  68. data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/integral.rb +2 -0
  69. data/lib/numbers_and_words/strategies/figures_converter/decorators/en.rb +2 -0
  70. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/base.rb +2 -0
  71. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/fractional.rb +2 -0
  72. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/integral.rb +2 -0
  73. data/lib/numbers_and_words/strategies/figures_converter/decorators/es.rb +2 -0
  74. data/lib/numbers_and_words/strategies/figures_converter/decorators/es/base.rb +2 -0
  75. data/lib/numbers_and_words/strategies/figures_converter/decorators/es/fractional.rb +3 -1
  76. data/lib/numbers_and_words/strategies/figures_converter/decorators/es/integral.rb +2 -0
  77. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr.rb +2 -0
  78. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/base.rb +2 -0
  79. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/fractional.rb +2 -0
  80. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/integral.rb +2 -0
  81. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu.rb +2 -0
  82. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/base.rb +2 -0
  83. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/fractional.rb +3 -1
  84. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/integral.rb +2 -0
  85. data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR.rb +2 -0
  86. data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/base.rb +2 -0
  87. data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/fractional.rb +2 -0
  88. data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/integral.rb +2 -0
  89. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru.rb +2 -0
  90. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/base.rb +2 -0
  91. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/fractional.rb +2 -0
  92. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/integral.rb +2 -0
  93. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua.rb +2 -0
  94. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/base.rb +2 -0
  95. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/fractional.rb +2 -0
  96. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/integral.rb +2 -0
  97. data/lib/numbers_and_words/strategies/figures_converter/decorators/vi.rb +5 -0
  98. data/lib/numbers_and_words/strategies/figures_converter/decorators/vi/base.rb +14 -0
  99. data/lib/numbers_and_words/strategies/figures_converter/decorators/vi/fractional.rb +14 -0
  100. data/lib/numbers_and_words/strategies/figures_converter/decorators/vi/integral.rb +14 -0
  101. data/lib/numbers_and_words/strategies/figures_converter/languages.rb +14 -15
  102. data/lib/numbers_and_words/strategies/figures_converter/languages/base.rb +4 -2
  103. data/lib/numbers_and_words/strategies/figures_converter/languages/cs.rb +4 -4
  104. data/lib/numbers_and_words/strategies/figures_converter/languages/de.rb +7 -7
  105. data/lib/numbers_and_words/strategies/figures_converter/languages/en-GB.rb +2 -0
  106. data/lib/numbers_and_words/strategies/figures_converter/languages/en.rb +3 -9
  107. data/lib/numbers_and_words/strategies/figures_converter/languages/es.rb +11 -13
  108. data/lib/numbers_and_words/strategies/figures_converter/languages/et.rb +2 -2
  109. data/lib/numbers_and_words/strategies/figures_converter/languages/families/base.rb +2 -0
  110. data/lib/numbers_and_words/strategies/figures_converter/languages/families/cyrillic.rb +2 -0
  111. data/lib/numbers_and_words/strategies/figures_converter/languages/families/helpers.rb +2 -0
  112. data/lib/numbers_and_words/strategies/figures_converter/languages/fr.rb +12 -12
  113. data/lib/numbers_and_words/strategies/figures_converter/languages/hu.rb +2 -2
  114. data/lib/numbers_and_words/strategies/figures_converter/languages/{families/latin.rb → hy.rb} +3 -4
  115. data/lib/numbers_and_words/strategies/figures_converter/languages/it.rb +2 -1
  116. data/lib/numbers_and_words/strategies/figures_converter/languages/ka.rb +13 -15
  117. data/lib/numbers_and_words/strategies/figures_converter/languages/lt.rb +8 -12
  118. data/lib/numbers_and_words/strategies/figures_converter/languages/lv.rb +4 -14
  119. data/lib/numbers_and_words/strategies/figures_converter/languages/nl.rb +3 -5
  120. data/lib/numbers_and_words/strategies/figures_converter/languages/pt-BR.rb +14 -12
  121. data/lib/numbers_and_words/strategies/figures_converter/languages/pt.rb +3 -3
  122. data/lib/numbers_and_words/strategies/figures_converter/languages/ru.rb +2 -0
  123. data/lib/numbers_and_words/strategies/figures_converter/languages/se.rb +2 -1
  124. data/lib/numbers_and_words/strategies/figures_converter/languages/tr.rb +4 -4
  125. data/lib/numbers_and_words/strategies/figures_converter/languages/ua.rb +2 -0
  126. data/lib/numbers_and_words/strategies/figures_converter/languages/vi.rb +100 -0
  127. data/lib/numbers_and_words/strategies/figures_converter/options.rb +15 -2
  128. data/lib/numbers_and_words/strategies/figures_converter/options/base.rb +5 -0
  129. data/lib/numbers_and_words/strategies/figures_converter/options/base/gender.rb +30 -0
  130. data/lib/numbers_and_words/strategies/figures_converter/options/base/ordinal.rb +28 -0
  131. data/lib/numbers_and_words/strategies/figures_converter/options/base/remove_zero.rb +30 -0
  132. data/lib/numbers_and_words/strategies/figures_converter/options/cs.rb +2 -0
  133. data/lib/numbers_and_words/strategies/figures_converter/options/cs/gender.rb +3 -14
  134. data/lib/numbers_and_words/strategies/figures_converter/options/cs/ordinal.rb +3 -15
  135. data/lib/numbers_and_words/strategies/figures_converter/options/cs/remove_zero.rb +3 -17
  136. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB.rb +2 -0
  137. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/hundreds_with_union.rb +2 -0
  138. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/ordinal.rb +2 -0
  139. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/pronounced.rb +2 -0
  140. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/remove_hyphen.rb +2 -0
  141. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/remove_zero.rb +2 -0
  142. data/lib/numbers_and_words/strategies/figures_converter/options/en.rb +2 -0
  143. data/lib/numbers_and_words/strategies/figures_converter/options/en/hundreds_with_union.rb +2 -0
  144. data/lib/numbers_and_words/strategies/figures_converter/options/en/ordinal.rb +3 -10
  145. data/lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb +6 -13
  146. data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_hyphen.rb +2 -0
  147. data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_zero.rb +3 -17
  148. data/lib/numbers_and_words/strategies/figures_converter/options/es.rb +2 -0
  149. data/lib/numbers_and_words/strategies/figures_converter/options/es/apocopated.rb +2 -0
  150. data/lib/numbers_and_words/strategies/figures_converter/options/es/gender.rb +3 -17
  151. data/lib/numbers_and_words/strategies/figures_converter/options/es/remove_zero.rb +3 -17
  152. data/lib/numbers_and_words/strategies/figures_converter/options/hu.rb +2 -0
  153. data/lib/numbers_and_words/strategies/figures_converter/options/hu/ordinal.rb +3 -50
  154. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR.rb +2 -0
  155. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/gender.rb +3 -18
  156. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/ordinal.rb +3 -15
  157. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/remove_zero.rb +3 -17
  158. data/lib/numbers_and_words/strategies/figures_converter/options/ru.rb +2 -0
  159. data/lib/numbers_and_words/strategies/figures_converter/options/ru/gender.rb +3 -17
  160. data/lib/numbers_and_words/strategies/figures_converter/options/ua.rb +2 -0
  161. data/lib/numbers_and_words/strategies/figures_converter/options/ua/gender.rb +3 -17
  162. data/lib/numbers_and_words/translations.rb +4 -0
  163. data/lib/numbers_and_words/translations/base.rb +3 -1
  164. data/lib/numbers_and_words/translations/cs.rb +6 -31
  165. data/lib/numbers_and_words/translations/de.rb +5 -3
  166. data/lib/numbers_and_words/translations/en-GB.rb +5 -1
  167. data/lib/numbers_and_words/translations/en.rb +2 -0
  168. data/lib/numbers_and_words/translations/es.rb +15 -25
  169. data/lib/numbers_and_words/translations/et.rb +4 -7
  170. data/lib/numbers_and_words/translations/extensions/fraction_significance.rb +6 -4
  171. data/lib/numbers_and_words/translations/families/base.rb +5 -3
  172. data/lib/numbers_and_words/translations/families/cyrillic.rb +6 -8
  173. data/lib/numbers_and_words/translations/families/latin.rb +2 -0
  174. data/lib/numbers_and_words/translations/fr.rb +15 -18
  175. data/lib/numbers_and_words/translations/hu.rb +4 -7
  176. data/lib/numbers_and_words/translations/hy.rb +21 -0
  177. data/lib/numbers_and_words/translations/it.rb +2 -0
  178. data/lib/numbers_and_words/translations/ka.rb +6 -14
  179. data/lib/numbers_and_words/translations/lt.rb +4 -11
  180. data/lib/numbers_and_words/translations/lv.rb +4 -11
  181. data/lib/numbers_and_words/translations/nl.rb +6 -2
  182. data/lib/numbers_and_words/translations/pt-BR.rb +23 -23
  183. data/lib/numbers_and_words/translations/pt.rb +5 -11
  184. data/lib/numbers_and_words/translations/ru.rb +2 -17
  185. data/lib/numbers_and_words/translations/se.rb +2 -0
  186. data/lib/numbers_and_words/translations/tr.rb +2 -4
  187. data/lib/numbers_and_words/translations/ua.rb +2 -13
  188. data/lib/numbers_and_words/translations/vi.rb +24 -0
  189. data/lib/numbers_and_words/version.rb +3 -1
  190. data/lib/numbers_and_words/wrappers.rb +2 -0
  191. data/lib/numbers_and_words/wrappers/float.rb +3 -1
  192. data/lib/numbers_and_words/wrappers/integer.rb +2 -0
  193. metadata +33 -20
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class De < Base
4
- include NumbersAndWords::Translations::Families::Latin
6
+ include NumbersAndWords::Translations::Families::Base
5
7
  DEFAULT_POSTFIX = :combine
6
8
 
7
9
  def ones(number, options = {})
@@ -9,11 +11,11 @@ module NumbersAndWords
9
11
  end
10
12
 
11
13
  def tens_with_ones(numbers, options = {})
12
- [tens(numbers[1]), ones(numbers[0], options)].reverse.join 'und'
14
+ [tens(numbers[1]), ones(numbers[0], options)].reverse.join(union)
13
15
  end
14
16
 
15
17
  def hundreds(number, _options = {})
16
- [ones(number), t(:hundreds)].join('')
18
+ [ones(number), t(:hundreds)].join
17
19
  end
18
20
 
19
21
  def zero(_options = {})
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
- class EnGb < En
5
+ class EnGb < Base
6
+ include NumbersAndWords::Translations::Families::Latin
7
+ include NumbersAndWords::Translations::Extensions::FractionSignificance
4
8
  end
5
9
  end
6
10
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class En < Base
@@ -1,47 +1,37 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class Es < Base
4
- include NumbersAndWords::Translations::Families::Latin
6
+ include NumbersAndWords::Translations::Families::Base
5
7
  include NumbersAndWords::Translations::Extensions::FractionSignificance
6
8
 
7
9
  def zero(_options = {})
8
- t(%i[ones male].join('.'))[0]
10
+ t('ones.male')[0]
9
11
  end
10
12
 
11
13
  def ones(number, options = {})
12
14
  return if options[:is_one_thousand]
13
- return t(%i[ones apocopated].join('.')) if number == 1 &&
14
- options[:is_apocopated]
15
- t([:ones, options[:gender]].join('.'))[number]
16
- end
15
+ return t('ones.apocopated') if number == 1 &&
16
+ options[:is_apocopated]
17
17
 
18
- def twenties_with_ones(numbers, options = {})
19
- return t(%i[twenties apocopated].join('.')) if options[:is_apocopated]
20
- t([:twenties, options[:gender]].join('.'))[numbers[0]]
18
+ t([:ones, options[:gender]].join('.'))[number]
21
19
  end
22
20
 
23
21
  def tens_with_ones(numbers, options = {})
24
- [tens(numbers[1], alone: false),
25
- t(:union),
26
- ones(numbers[0], options)].join(' ')
22
+ super numbers, options.merge(separator: " #{union} ")
27
23
  end
28
24
 
29
- def hundreds(number, options = {})
30
- return t(%i[hundreds apocopated].join('.')) if options[:is_apocopated]
31
- t([:hundreds, options[:gender]].join('.'))[number]
32
- end
25
+ def twenties_with_ones(numbers, options = {})
26
+ return t('twenties.apocopated') if options[:is_apocopated]
33
27
 
34
- def micros(capacity, number = nil)
35
- micro, prefix = capacity
36
- micros = number ? t(micro(micro), count: number) : micro(micro)
37
- [micro_prefix(prefix), micros].compact.join
28
+ t([:twenties, options[:gender]].join('.'))[numbers[0]]
38
29
  end
39
30
 
40
- def micro_prefix(capacity)
41
- case capacity
42
- when 2 then t('micro_prefix.hundreds')
43
- when 1 then t('micro_prefix.tens')
44
- end
31
+ def hundreds(number, options = {})
32
+ return t('hundreds.apocopated') if options[:is_apocopated]
33
+
34
+ t([:hundreds, options[:gender]].join('.'))[number]
45
35
  end
46
36
  end
47
37
  end
@@ -1,15 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class Et < Base
4
6
  include NumbersAndWords::Translations::Families::Latin
5
7
 
6
- def tens_with_ones(numbers, _options = {})
7
- [tens(numbers[1], alone: false), ones(numbers[0])].join ' '
8
- end
9
-
10
- def hundreds(number, options = {})
11
- options[:separator] = ''
12
- super number, options
8
+ def hundreds(number, _options = {})
9
+ super number, separator: ''
13
10
  end
14
11
  end
15
12
  end
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  module Extensions
4
6
  module FractionSignificance
5
- def micros(capacity, number = nil, separator = '-')
7
+ def micros(capacity, number = nil)
6
8
  micro, prefix = capacity
7
9
  micros = number ? t(micro(micro), count: number) : micro(micro)
8
- [micro_prefix(prefix), micros].compact.join separator
10
+ [micro_prefix(prefix), micros].compact.join(t('micro_prefix.union'))
9
11
  end
10
12
 
11
13
  def micro(capacity)
@@ -14,8 +16,8 @@ module NumbersAndWords
14
16
 
15
17
  def micro_prefix(capacity)
16
18
  case capacity
17
- when 2 then t(:hundreds)
18
- when 1 then tens(1)
19
+ when 2 then t('micro_prefix.hundreds')
20
+ when 1 then t('micro_prefix.tens')
19
21
  end
20
22
  end
21
23
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  module Families
@@ -11,7 +13,7 @@ module NumbersAndWords
11
13
  end
12
14
 
13
15
  def tens_with_ones(numbers, options = {})
14
- [tens(numbers[1]), ones(numbers[0], options)].join options[:separator]
16
+ [tens(numbers[1]), ones(numbers[0], options)].join options[:separator] || ' '
15
17
  end
16
18
 
17
19
  def megs(capacity, options = {})
@@ -28,8 +30,8 @@ module NumbersAndWords
28
30
  t :union
29
31
  end
30
32
 
31
- def union_separator
32
- t :union_separator
33
+ def micro_separator
34
+ t :micro_separator
33
35
  end
34
36
  end
35
37
  end
@@ -1,25 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  module Families
4
6
  module Cyrillic
5
7
  include NumbersAndWords::Translations::Families::Base
6
8
 
7
- def ones(number, options = {})
8
- t(:ones)[options[:gender]][number]
9
+ def zero(_options = {})
10
+ t(:ones).values.first[0]
9
11
  end
10
12
 
11
- def tens_with_ones(numbers, options = {})
12
- [tens(numbers[1]), ones(numbers[0], options)].join ' '
13
+ def ones(number, options = {})
14
+ t(:ones)[options[:gender]][number]
13
15
  end
14
16
 
15
17
  def hundreds(number, _options = {})
16
18
  t(:hundreds)[number]
17
19
  end
18
20
 
19
- def zero(_options = {})
20
- t(:ones).values.first[0]
21
- end
22
-
23
21
  def integral(number, _options = {})
24
22
  t(:integral, count: number)
25
23
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  module Families
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class Fr < Base
@@ -7,30 +9,25 @@ module NumbersAndWords
7
9
  SPECIAL_TENS_CASE = 8
8
10
 
9
11
  def tens(number, options = {})
10
- options[:alone] = true if options[:alone].nil?
11
- SPECIAL_TENS_CASE == number && options[:alone] ? t(:eighty) : super(number)
12
+ return t(:eighty) if number == SPECIAL_TENS_CASE && options[:alone].nil?
13
+
14
+ super number, options
12
15
  end
13
16
 
14
- def tens_with_ones(numbers, _options = {})
15
- if [7, 9].include? numbers[1]
16
- [tens(numbers[1] - 1, alone: false), teens(numbers)].join '-'
17
- else
18
- union = numbers[0] == 1 ? ' et ' : '-'
19
- [tens(numbers[1], alone: false), ones(numbers[0])].join union
20
- end
17
+ def tens_with_ones(numbers, options = {})
18
+ return [tens(numbers[1] - 1, alone: false), teens(numbers)].join('-') if [7, 9].include? numbers[1]
19
+
20
+ separator = numbers[0] == 1 ? " #{union} " : '-'
21
+ super numbers, options.merge(separator: separator)
21
22
  end
22
23
 
23
24
  def hundreds(number, options = {})
24
- options[:pluralize] = false if options[:pluralize].nil?
25
- hundreds = t(:hundreds, count: options[:pluralize] ? number : 1)
26
- number == 1 ? hundreds : [t(:ones)[number], hundreds].join(' ')
27
- end
25
+ count = options[:pluralize] ? number : 1
26
+ hundreds = t(:hundreds, count: count)
27
+
28
+ return hundreds if number == 1
28
29
 
29
- def micro_prefix(capacity)
30
- case capacity
31
- when 2 then t(:hundreds, count: 1)
32
- when 1 then tens(1)
33
- end
30
+ [t(:ones)[number], hundreds].join(' ')
34
31
  end
35
32
  end
36
33
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class Hu < Base
@@ -6,16 +8,11 @@ module NumbersAndWords
6
8
 
7
9
  def tens_with_ones(numbers, options = {})
8
10
  ones, tens = numbers
9
- [t(:tens_with_ones)[tens], t([options[:prefix], :ones_with_tens].join('.'))[ones]].join ''
11
+ [t(:tens_with_ones)[tens], t([options[:prefix], :ones_with_tens].join('.'))[ones]].join
10
12
  end
11
13
 
12
14
  def hundreds(number, options = {})
13
- options[:separator] = ''
14
- super number, options
15
- end
16
-
17
- def micros(capacity, _number = nil, separator = '')
18
- super capacity, nil, separator
15
+ super number, options.merge(separator: '')
19
16
  end
20
17
  end
21
18
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NumbersAndWords
4
+ module Translations
5
+ class Hy < Base
6
+ include NumbersAndWords::Translations::Families::Latin
7
+
8
+ def tens_with_ones(numbers, options = {})
9
+ options[:separator] ||= ''
10
+ super
11
+ end
12
+
13
+ def hundreds(number, _options = {})
14
+ parts = [t(:hundreds)]
15
+ parts.unshift(t(:ones)[number]) if number > 1
16
+
17
+ parts.join(' ')
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class It < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class Ka < Base
@@ -40,32 +42,22 @@ module NumbersAndWords
40
42
  def tens_with_ones(numbers, _options = {})
41
43
  range = vigesimal_range(numbers[1])
42
44
 
43
- minor = if numbers[1] - range[:multiplicative] > 0
45
+ minor = if (numbers[1] - range[:multiplicative]).positive?
44
46
  teens(numbers)
45
47
  else
46
48
  ones(numbers[0])
47
49
  end
48
50
 
49
- [t([:partials, range[:name]].join('.')), minor].join ''
51
+ [t([:partials, range[:name]].join('.')), minor].join
50
52
  end
51
53
 
52
54
  def hundreds(number, options = {})
53
55
  options[:prefix] ||= options[:only_hundreds] == true ? nil : :partials
54
56
 
55
- parts = [t([options[:prefix], :one_hundred].join('.'))]
57
+ parts = [t([options[:prefix], :hundreds].join('.'))]
56
58
  parts.unshift(ones(number, prefix: :partials)) if number > 1
57
59
 
58
- parts.join ''
59
- end
60
-
61
- def megs(capacity, options = {})
62
- if capacity == 1
63
- t([options[:prefix], :one_thousand].join('.'))
64
- elsif capacity == 2
65
- t([options[:prefix], :one_million].join('.'))
66
- elsif capacity == 3
67
- t([options[:prefix], :one_billion].join('.'))
68
- end
60
+ parts.join
69
61
  end
70
62
  end
71
63
  end
@@ -1,19 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class Lt < Base
4
6
  include NumbersAndWords::Translations::Families::Latin
5
7
 
6
- def tens(number, _options = {})
7
- super(number)
8
- end
9
-
10
- def tens_with_ones(numbers, _options = {})
11
- [tens(numbers[1], alone: false), ones(numbers[0])].join ' '
12
- end
13
-
14
- def hundreds(number, options = {})
15
- options[:is_hundred] = false if options[:is_hundred].nil?
16
- options[:is_hundred] ? t(:one_hundred) : t(:hundreds)[number - 1]
8
+ def hundreds(number, _options = {})
9
+ t(:hundreds)[number]
17
10
  end
18
11
  end
19
12
  end
@@ -1,19 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class Lv < Base
4
6
  include NumbersAndWords::Translations::Families::Latin
5
7
 
6
- def tens(number, _options = {})
7
- super(number)
8
- end
9
-
10
- def tens_with_ones(numbers, _options = {})
11
- [tens(numbers[1], alone: false), ones(numbers[0])].join ' '
12
- end
13
-
14
- def hundreds(number, options = {})
15
- options[:is_hundred] = false if options[:is_hundred].nil?
16
- options[:is_hundred] ? t(:one_hundred) : t(:hundreds)[number - 1]
8
+ def hundreds(number, _options = {})
9
+ t(:hundreds)[number]
17
10
  end
18
11
  end
19
12
  end
@@ -1,14 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class Nl < Base
4
6
  include NumbersAndWords::Translations::Families::Latin
5
7
 
6
8
  def tens_with_ones(numbers, _options = {})
7
- [ones(numbers[0]), tens(numbers[1])].join 'en'
9
+ [ones(numbers[0]), tens(numbers[1])].join(union)
8
10
  end
9
11
 
10
12
  def hundreds(number, _options = {})
11
- number == 1 ? t(:hundreds) : [t(:ones)[number], t(:hundreds)].join
13
+ return t(:hundreds) if number == 1
14
+
15
+ super number, separator: ''
12
16
  end
13
17
  end
14
18
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Translations
3
5
  class PtBr < Base
4
- include NumbersAndWords::Translations::Families::Latin
6
+ include NumbersAndWords::Translations::Families::Base
5
7
  include NumbersAndWords::Translations::Extensions::FractionSignificance
6
8
 
7
9
  def integral(number, _options = {})
@@ -14,50 +16,48 @@ module NumbersAndWords
14
16
 
15
17
  def ones(number, options = {})
16
18
  return if options[:is_one_thousand]
19
+
17
20
  t([options[:prefix], :ones, options[:gender]].join('.'))[number]
18
21
  end
19
22
 
20
23
  def tens(number, options = {})
21
- options[:alone] = true if options[:alone].nil?
22
24
  path = [options[:prefix], :tens]
23
- path.push(options[:gender]) if ordinal? options
24
- translated = t(path.join('.'))[number]
25
- options[:alone] ? translated : "#{union} " + translated
25
+ path.push(options[:gender]) if ordinal?(options)
26
+ t(path.join('.'))[number]
26
27
  end
27
28
 
28
29
  def teens(number, options = {})
29
- return [tens(1, options), ' ', ones(number[0], options)].join if ordinal? options
30
+ return [tens(1, options), ones(number[0], options)].join(' ') if ordinal? options
31
+
30
32
  super(number, options)
31
33
  end
32
34
 
33
35
  def tens_with_ones(numbers, options = {})
34
- connector = ' '
35
- connector = " #{union} " unless ordinal? options
36
- [tens(numbers[1], options), connector, ones(numbers[0], options)].join
36
+ connector = ordinal?(options) ? ' ' : " #{union} "
37
+ [tens(numbers[1], options), ones(numbers[0], options)].join(connector)
37
38
  end
38
39
 
39
40
  def hundreds(number, options = {})
40
- return t(:one_hundred) if options[:is_one_hundred] && !(ordinal? options)
41
- translated = t([options[:prefix], :hundreds, options[:gender]].join('.'))[number - 1]
42
- return translated if ordinal? options
43
- options[:is_hundred] ? translated : translated + " #{union}"
41
+ return t(:one_hundred) if options[:is_one_hundred] && !ordinal?(options)
42
+
43
+ hundreds = t([options[:prefix], :hundreds, options[:gender]].join('.'))[number]
44
+ return hundreds if ordinal?(options) || options[:is_hundred]
45
+
46
+ [hundreds, union].join(' ')
44
47
  end
45
48
 
46
49
  def megs(capacity, options = {})
47
- return t([options[:prefix], :mega, options[:gender]].join('.'))[capacity] if ordinal? options
48
-
49
- options[:is_one] = false if options[:is_one].nil?
50
- connector = " #{union}"
51
- connector = ',' if options[:is_with_comma]
52
- suffix = options[:is_opaque] ? '' : connector
53
- suffix = options[:is_without_connector] ? '' : suffix
54
- (options[:is_one] ? t(:mega)[capacity] : t(:megas)[capacity]) + suffix
50
+ return t([options[:prefix], :mega, options[:gender]].join('.'))[capacity] if ordinal?(options)
51
+ return super(capacity, options) if options[:is_opaque] || options[:is_without_connector]
52
+
53
+ suffix = options[:is_with_comma] ? ',' : " #{union}"
54
+ super(capacity, options) + suffix
55
55
  end
56
56
 
57
- def micros(capacity, number, separator = t('micro_prefix.separator'))
57
+ def micros(capacity, number = nil)
58
58
  micro, prefix = capacity
59
59
  micros = number ? t(micro(micro), count: number) : micro(micro)
60
- [micro_prefix(prefix, number), micros].compact.join(" #{separator} ")
60
+ [micro_prefix(prefix, number), micros].compact.join(t('micro_prefix.union'))
61
61
  end
62
62
 
63
63
  def micro_prefix(capacity, number)