numbers_and_words 0.8.0 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14b6c2ee5f7c2b5803ea7a19d4a3ca3441db4435
4
- data.tar.gz: 459a289fa37ac62d3434560976b7a59f50c94c95
3
+ metadata.gz: ae33962e8692a09e263c4364ca5d8cef234be033
4
+ data.tar.gz: f2e4fc1eec9e9d7e7f9ab53075f0c0eb9b91f9f1
5
5
  SHA512:
6
- metadata.gz: cfb6bebd6a761b1b74e0596fc0ea4090f19f673c6e6f32374d99075ea945038adfe52707c00d845888112838a29c33b2606c444265c712408136bf87fa29d198
7
- data.tar.gz: e74db64eb655bd469aba22ea94d8ef5f1ac00d973b5378e4283ea40c913ad84276d50f0d9903dc2a2562a6b6e6c6158e68ac95b43189e145e94f6c35dc6962fc
6
+ metadata.gz: f2acb690a2af4c547ffb18d823f68cbba2adc0e2575c31ffdfa5e47a33f95fe70346fcafd90baa6b5680c1525fb461c398bbc022a683e27846f38e7f9eb614bb
7
+ data.tar.gz: b1e2a82182a2938a9a608729aac900bebca686e8acb37d8d2fe735ccac81d8e94c75c06dccd9d8d0d6ea44f2cb10463db6c38e1a02a157ad0443e8adbefa7ef6
data/README.rdoc CHANGED
@@ -22,7 +22,9 @@ Számok betűvel írva az I18n könyvtár segítségével.
22
22
  * Français [fr]
23
23
  * Українська [ua]
24
24
  * Magyar [hu]
25
+ * Latviešu [lv]
25
26
  * Türkçe** [tr]
27
+ * Deutsch** [de]
26
28
  * Italiano** [it]
27
29
  * Nederlands** [nl]
28
30
  * Swedish** [se]
@@ -33,6 +35,7 @@ Számok betűvel írva az I18n könyvtár segítségével.
33
35
  * {[en-AU], [en-CA], [en-IN], [en-US]}*** => [en]
34
36
  * {[es-419], [es-AR], [es-CL], [es-CO], [es-MX], [es-PE], [es-VE]}*** => [es]
35
37
  * {[fr-CA], [fr-CH]}*** => [fr]
38
+ * {[de], [de-AT], [de-CH]}*** => [de]
36
39
  * {[it-CH]}*** => [it]
37
40
 
38
41
  *** Aliases
@@ -54,6 +57,9 @@ Számok betűvel írva az I18n könyvtár segítségével.
54
57
  I18n.with_locale(:hu) { 42.to_words }
55
58
  => "negyvenkettő"
56
59
 
60
+ I18n.with_locale(:lv) { 42.to_words }
61
+ => "četrdesmit divi"
62
+
57
63
  21.to_words
58
64
  => "twenty-one"
59
65
  => "veintiuno"
@@ -62,9 +68,11 @@ Számok betűvel írva az I18n könyvtár segítségével.
62
68
  => "двадцять один"
63
69
  => "huszonegy"
64
70
  => "yirmi bir"
71
+ => "einundzwanzig"
65
72
  => "ventiuno"
66
73
  => "éénentwintig"
67
74
  => "tjugo-en"
75
+ => "divdesmit viens"
68
76
 
69
77
  231.to_words
70
78
  => "two hundred thirty-one"
@@ -74,9 +82,11 @@ Számok betűvel írva az I18n könyvtár segítségével.
74
82
  => "двiстi тридцять один"
75
83
  => "kettőszázharmincegy"
76
84
  => "iki yüz otuz bir"
85
+ => "zweihunderteinunddreißig"
77
86
  => "2 cento trentauno"
78
87
  => "tweehonderdéénendertig"
79
88
  => "två hundra trettio-en"
89
+ => "divi simti trīsdesmit viens"
80
90
 
81
91
  4030.to_words
82
92
  => "four thousand thirty"
@@ -86,9 +96,11 @@ Számok betűvel írva az I18n könyvtár segítségével.
86
96
  => "чотири тисячi тридцять"
87
97
  => "négyezer-harminc"
88
98
  => "dört bin otuz"
99
+ => "viertausenddreißig"
89
100
  => "quattro mille trenta"
90
101
  => "vierthousanddertig"
91
102
  => "fyra tusen trettio"
103
+ => "četri tūkstoši simts trīsdesmit"
92
104
 
93
105
  1000100.to_words
94
106
  => "one million one hundred"
@@ -98,9 +110,11 @@ Számok betűvel írva az I18n könyvtár segítségével.
98
110
  => "один мiльйон сто"
99
111
  => "egymillió-egyszáz"
100
112
  => "bir milyon bir yüz"
113
+ => "eine Million einhundert"
101
114
  => "uno milione 1 cento"
102
115
  => "één miljoen honderd"
103
116
  => "en miljoner en hundra"
117
+ => "viens miljons simts"
104
118
 
105
119
  1000000000000000000000000000000000.to_words
106
120
  => "one decillion"
@@ -110,9 +124,11 @@ Számok betűvel írva az I18n könyvtár segítségével.
110
124
  => "один децильйон"
111
125
  => "egykvintilliárd"
112
126
  => "bir desilyon"
127
+ => "eine Quintilliarde"
113
128
  => "uno decillion"
114
129
  => "één decillion"
115
130
  => "en decillion"
131
+ => "viens deciljons"
116
132
 
117
133
  [1, 2, 3].to_words
118
134
  => ["one", "two", "three"]
@@ -120,6 +136,7 @@ Számok betűvel írva az I18n könyvtár segítségével.
120
136
  => ["один", "два", "три"]
121
137
  => ["un", "deux", "trois"]
122
138
  => ["egy", "kettő", "három"]
139
+ => ["viens", "divi", "trīs"]
123
140
 
124
141
  [11, 22, 133].to_words
125
142
  => ["eleven", "twenty-two", "one hundred thirty-three"]
@@ -129,9 +146,11 @@ Számok betűvel írva az I18n könyvtár segítségével.
129
146
  => ["одинадцять", "двадцять два", "сто тридцять три"]
130
147
  => ["tizenegy", "huszonkettő", "egyszázharminchárom"]
131
148
  => ["on bir", "yirmi iki", "bir yüz otuz üç"]
149
+ => ["elf", "zweiundzwanzig", "einhundertdreiunddreißig"]
132
150
  => ["undici", "ventidue", "1 cento trentatre"]
133
151
  => ["elf", "tweeentwintig", "honderddrieendertig"]
134
152
  => ["elva", "tjugo-två", "en hundra trettio-tre"]
153
+ => ["vienpadsmit", "divdesmit divi", "simts trīsdesmit trīs"]
135
154
 
136
155
  21.77.to_words
137
156
  => "twenty-one and seventy-seven hundredths"
@@ -216,3 +235,4 @@ Send a pull request. Bonus points for topic branches.
216
235
  * Sergey Shkirando (mailto:shkirando.s@yandex.ru)
217
236
  * Ulrich Sossou (Github[http://github.com/sorich87], {Personal Page}[http://ulrichsossou.com/])
218
237
  * eLod (link:http://github.com/eLod)
238
+ * Mārtiņš Spriņģis (mailto:mspringis@gmail.com)
@@ -0,0 +1,43 @@
1
+ de:
2
+ numbers:
3
+ ones:
4
+ default: ['null', eins, zwei, drei, vier, fünf, sechs, sieben, acht, neun]
5
+ combine: ['null', ein, zwei, drei, vier, fünf, sechs, sieben, acht, neun]
6
+ gender: ['null', eine, zwei, drei, vier, fünf, sechs, sieben, acht, neun]
7
+ teens: [zehn, elf, zwölf, dreizehn, vierzehn, fünfzehn, sechzehn, siebzehn, achtzehn, neunzehn]
8
+ tens: [null, zehn, zwanzig, dreißig, vierzig, fünfzig, sechzig, siebzig, achtzig, neunzig]
9
+ mega: [ones, thousands, millions, billions, trillions, quadrillions, quintillion, sextillions, septillions, octillions, nonillions, decillions]
10
+ hundreds: hundert
11
+ thousands:
12
+ one: tausend
13
+ other: tausend
14
+ millions:
15
+ one: Million
16
+ other: Millionen
17
+ billions:
18
+ one: Milliarde
19
+ other: Milliarden
20
+ trillions:
21
+ one: Billion
22
+ other: Billionen
23
+ quadrillions:
24
+ one: Billiarde
25
+ other: Billiaden
26
+ quintillions:
27
+ one: Trillion
28
+ other: Trillionen
29
+ sextillions:
30
+ one: Trilliarde
31
+ other: Trilliarden
32
+ septillions:
33
+ one: Quadrillion
34
+ other: Quadrillionen
35
+ octillions:
36
+ one: Quadrilliarde
37
+ other: Quadrilliarden
38
+ nonillions:
39
+ one: Quintillion
40
+ other: Quintillionen
41
+ decillions:
42
+ one: Quintilliarde
43
+ other: Quintilliarden
@@ -0,0 +1,41 @@
1
+ lv:
2
+ numbers:
3
+ ones: [nulle, viens, divi, trīs, četri, pieci, seši, septiņi, astoņi, deviņi]
4
+ teens: [desmit, vienpadsmit, divpadsmit, trīspadsmit, čatrpadsmit, piecpadsmit, sešpadsmit, septiņpadsmit, astoņpadsmit, deviņpadsmit]
5
+ tens: [nulle, desmit, divdesmit, trīsdesmit, četrdesmit, piecdesmit, sešdesmit, septiņdesmit, astoņdesmit, deviņdesmit]
6
+ mega: [ones, thousands, millions, billions, trillions, quadrillions, quintillion, sextillions, septillions, octillions, nonillions, decillions]
7
+ hundreds: [simts, divi simti, trīs simti, četri simti, pieci simti, seši simti, septiņi simti, astoņi simti, deviņi simti]
8
+ one_hundred: simts
9
+ thousands:
10
+ one: tūkstots
11
+ other: tūkstoši
12
+ millions:
13
+ one: miljons
14
+ other: miljoni
15
+ billions:
16
+ one: miljards
17
+ other: miljardi
18
+ trillions:
19
+ one: triljons
20
+ other: triljoni
21
+ quadrillions:
22
+ one: kvadriljons
23
+ other: kvadriljoni
24
+ quintillions:
25
+ one: kvintiljons
26
+ other: kvintiljoni
27
+ sextillions:
28
+ one: sekstiljons
29
+ other: sekstiljoni
30
+ septillions:
31
+ one: septiljons
32
+ other: septiljoni
33
+ octillions:
34
+ one: oktiljons
35
+ other: oktiljoni
36
+ nonillions:
37
+ one: noniljons
38
+ other: noniljoni
39
+ decillions:
40
+ one: deciljons
41
+ other: deciljoni
@@ -2,6 +2,7 @@ require 'numbers_and_words/i18n/plurals/ru'
2
2
  require 'numbers_and_words/i18n/plurals/ua'
3
3
  require 'numbers_and_words/i18n/plurals/fr'
4
4
  require 'numbers_and_words/i18n/plurals/es'
5
+ require 'numbers_and_words/i18n/plurals/lv'
5
6
 
6
7
  module NumbersAndWords
7
8
  module I18n
@@ -0,0 +1,15 @@
1
+ module NumbersAndWords
2
+ module I18n
3
+ module Plurals
4
+ module Lv
5
+ RULE = lambda { |n| one_conditions(n) ? :one : :other }
6
+
7
+ extend self
8
+
9
+ def one_conditions n
10
+ n % 10 == 1 && n % 100 != 11
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -14,6 +14,8 @@ require 'numbers_and_words/strategies/figures_converter/languages/it'
14
14
  require 'numbers_and_words/strategies/figures_converter/languages/nl'
15
15
  require 'numbers_and_words/strategies/figures_converter/languages/tr'
16
16
  require 'numbers_and_words/strategies/figures_converter/languages/es'
17
+ require 'numbers_and_words/strategies/figures_converter/languages/lv'
18
+ require 'numbers_and_words/strategies/figures_converter/languages/de'
17
19
 
18
20
  require 'numbers_and_words/strategies/figures_converter/languages/families/cyrillic'
19
21
 
@@ -0,0 +1,66 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Languages
5
+ class De < Base
6
+ include Families::Latin
7
+
8
+ def print_words
9
+ 1 < complex_part.count ? print_megs_words : @strings.flatten.reverse.join('')
10
+ end
11
+
12
+ def print_megs_words
13
+ [print_megs, print_other].select(&:present?).join ' '
14
+ end
15
+
16
+ def complex_number_to_words
17
+ (1..@figures.capacity_count).map { |capacity|
18
+ @current_capacity = capacity
19
+ capacity_iteration
20
+ }
21
+ end
22
+
23
+ def ones
24
+ super(:postfix => postfix)
25
+ end
26
+
27
+ def postfix
28
+ case (@current_capacity ||= 0)
29
+ when 1 then :combine
30
+ when 0 then :default
31
+ else :gender
32
+ end
33
+ end
34
+
35
+ def megs
36
+ super({:number => @figures.number_in_capacity(@current_capacity)})
37
+ end
38
+
39
+ private
40
+
41
+ def print_megs
42
+ complex_part[1..-1].map { |el|
43
+ [el[1..-1].to_a.reverse.join(''), el.first].join(' ')
44
+ }.select(&:present?).reverse.join(' ')
45
+ end
46
+
47
+ def print_other
48
+ [print_thousands, simple_part.reverse.join('')].join('')
49
+ end
50
+
51
+ def print_thousands
52
+ complex_part.first.reverse.join('')
53
+ end
54
+
55
+ def simple_part
56
+ @strings.select { |f| !f.is_a?(Array) }
57
+ end
58
+
59
+ def complex_part
60
+ @strings - simple_part
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,37 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Languages
5
+ class Lv < Base
6
+ include Families::Latin
7
+
8
+ private
9
+
10
+ def capacity_iteration
11
+ words = []
12
+ capacity_words = words_in_capacity(@current_capacity)
13
+ words.push(megs) unless capacity_words.empty?
14
+ words += capacity_words unless is_a_thousand? and is_a_one?
15
+ words
16
+ end
17
+
18
+ def is_a_one?
19
+ [translations.ones(1)] == words_in_capacity(@current_capacity)
20
+ end
21
+
22
+ def is_a_thousand?
23
+ FiguresArray::THOUSAND_CAPACITY == @current_capacity
24
+ end
25
+
26
+ def hundreds
27
+ super({:is_hundred => (figures[1,2] == [0,1] && simple_number_to_words.empty?)})
28
+ end
29
+
30
+ def megs
31
+ super({:number => @figures.number_in_capacity(@current_capacity)})
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -14,6 +14,8 @@ require 'numbers_and_words/translations/it'
14
14
  require 'numbers_and_words/translations/hu'
15
15
  require 'numbers_and_words/translations/se'
16
16
  require 'numbers_and_words/translations/es'
17
+ require 'numbers_and_words/translations/lv'
18
+ require 'numbers_and_words/translations/de'
17
19
 
18
20
  module NumbersAndWords
19
21
  module Translations
@@ -0,0 +1,24 @@
1
+ module NumbersAndWords
2
+ module Translations
3
+ class De < Base
4
+ include NumbersAndWords::Translations::Families::Latin
5
+ DEFAULT_POSTFIX = :combine
6
+
7
+ def ones number, options = {}
8
+ t([options[:prefix], :ones, options[:postfix] || DEFAULT_POSTFIX].join('.'))[number]
9
+ end
10
+
11
+ def tens_with_ones numbers, options = {}
12
+ [tens(numbers[1]), ones(numbers[0], options)].reverse.join 'und'
13
+ end
14
+
15
+ def hundreds number, options = {}
16
+ [ones(number), t(:hundreds)].join('')
17
+ end
18
+
19
+ def zero options = {}
20
+ ones 0
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ module NumbersAndWords
2
+ module Translations
3
+ class Lv < Base
4
+ include NumbersAndWords::Translations::Families::Latin
5
+
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
+
15
+ def hundreds number, options = {}
16
+ options[:is_hundred] = false if options[:is_hundred].nil?
17
+ options[:is_hundred] ? t(:one_hundred) : t(:hundreds)[number - 1]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module NumbersAndWords
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numbers_and_words
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Lazarev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-29 00:00:00.000000000 Z
11
+ date: 2013-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -86,12 +86,14 @@ files:
86
86
  - lib/numbers_and_words/helper_classes/words_array.rb
87
87
  - lib/numbers_and_words/i18n.rb
88
88
  - lib/numbers_and_words/i18n/initialization.rb
89
+ - lib/numbers_and_words/i18n/locales/numbers.de.yml
89
90
  - lib/numbers_and_words/i18n/locales/numbers.en-GB.yml
90
91
  - lib/numbers_and_words/i18n/locales/numbers.en.yml
91
92
  - lib/numbers_and_words/i18n/locales/numbers.es.yml
92
93
  - lib/numbers_and_words/i18n/locales/numbers.fr.yml
93
94
  - lib/numbers_and_words/i18n/locales/numbers.hu.yml
94
95
  - lib/numbers_and_words/i18n/locales/numbers.it.yml
96
+ - lib/numbers_and_words/i18n/locales/numbers.lv.yml
95
97
  - lib/numbers_and_words/i18n/locales/numbers.nl.yml
96
98
  - lib/numbers_and_words/i18n/locales/numbers.ru.yml
97
99
  - lib/numbers_and_words/i18n/locales/numbers.se.yml
@@ -100,6 +102,7 @@ files:
100
102
  - lib/numbers_and_words/i18n/pluralization.rb
101
103
  - lib/numbers_and_words/i18n/plurals/es.rb
102
104
  - lib/numbers_and_words/i18n/plurals/fr.rb
105
+ - lib/numbers_and_words/i18n/plurals/lv.rb
103
106
  - lib/numbers_and_words/i18n/plurals/plurals.rb
104
107
  - lib/numbers_and_words/i18n/plurals/ru.rb
105
108
  - lib/numbers_and_words/i18n/plurals/ua.rb
@@ -138,6 +141,7 @@ files:
138
141
  - lib/numbers_and_words/strategies/figures_converter/decorators/ua/integral.rb
139
142
  - lib/numbers_and_words/strategies/figures_converter/languages.rb
140
143
  - lib/numbers_and_words/strategies/figures_converter/languages/base.rb
144
+ - lib/numbers_and_words/strategies/figures_converter/languages/de.rb
141
145
  - lib/numbers_and_words/strategies/figures_converter/languages/en.rb
142
146
  - lib/numbers_and_words/strategies/figures_converter/languages/en_gb.rb
143
147
  - lib/numbers_and_words/strategies/figures_converter/languages/es.rb
@@ -148,6 +152,7 @@ files:
148
152
  - lib/numbers_and_words/strategies/figures_converter/languages/fr.rb
149
153
  - lib/numbers_and_words/strategies/figures_converter/languages/hu.rb
150
154
  - lib/numbers_and_words/strategies/figures_converter/languages/it.rb
155
+ - lib/numbers_and_words/strategies/figures_converter/languages/lv.rb
151
156
  - lib/numbers_and_words/strategies/figures_converter/languages/nl.rb
152
157
  - lib/numbers_and_words/strategies/figures_converter/languages/ru.rb
153
158
  - lib/numbers_and_words/strategies/figures_converter/languages/se.rb
@@ -172,6 +177,7 @@ files:
172
177
  - lib/numbers_and_words/strategies/figures_converter/options/ua/gender.rb
173
178
  - lib/numbers_and_words/translations.rb
174
179
  - lib/numbers_and_words/translations/base.rb
180
+ - lib/numbers_and_words/translations/de.rb
175
181
  - lib/numbers_and_words/translations/en.rb
176
182
  - lib/numbers_and_words/translations/en_gb.rb
177
183
  - lib/numbers_and_words/translations/es.rb
@@ -182,6 +188,7 @@ files:
182
188
  - lib/numbers_and_words/translations/fr.rb
183
189
  - lib/numbers_and_words/translations/hu.rb
184
190
  - lib/numbers_and_words/translations/it.rb
191
+ - lib/numbers_and_words/translations/lv.rb
185
192
  - lib/numbers_and_words/translations/nl.rb
186
193
  - lib/numbers_and_words/translations/ru.rb
187
194
  - lib/numbers_and_words/translations/se.rb