numbers_and_words 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/README.rdoc +18 -11
- data/lib/numbers_and_words/helper_classes/figures_array.rb +5 -1
- data/lib/numbers_and_words/helper_classes/words_array.rb +5 -1
- data/lib/numbers_and_words/i18n.rb +21 -0
- data/lib/numbers_and_words/i18n/initialization.rb +1 -13
- data/lib/numbers_and_words/strategies/array_joiner/languages.rb +1 -5
- data/lib/numbers_and_words/strategies/figures_converter/decorators.rb +1 -5
- data/lib/numbers_and_words/strategies/figures_converter/languages.rb +1 -5
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/cyrillic.rb +3 -1
- data/lib/numbers_and_words/strategies/figures_converter/options.rb +1 -5
- data/lib/numbers_and_words/translations.rb +1 -5
- data/lib/numbers_and_words/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MGI3NjJkY2E1OWM2OTFhNzZmZmY4NjFhNGNhY2QwZGZhN2RmZjE0YjJlNzUw
|
10
|
-
MTAzNmZiMDY0MzJiOWFjZGY0N2JlZjVlYTVlZTNjZGQzNGNiZTU3YjJlMTFm
|
11
|
-
ZDM5YTQ2NjYzZjAxZDkyYzI2Y2EzZGRkMzU5NGZkYWMxMjMyNzk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NjAwODNmZDFkMjE0ODc5ZGI0Y2M3YWYwNmU1M2ZlOTY1YTdiM2IxMmM2MWMx
|
14
|
-
ZDM4MDIzNmJlNWFmMjY3Y2M3ODMxMWU1ZmE1ZmU3NDUxZTc0MTYxMTk5Y2Ew
|
15
|
-
ZTY2YmFkYzQzMDM4NzEzYjg0NjE0ODI1ZGQ2YjJiZTFmMmFjNjU=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 14b6c2ee5f7c2b5803ea7a19d4a3ca3441db4435
|
4
|
+
data.tar.gz: 459a289fa37ac62d3434560976b7a59f50c94c95
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cfb6bebd6a761b1b74e0596fc0ea4090f19f673c6e6f32374d99075ea945038adfe52707c00d845888112838a29c33b2606c444265c712408136bf87fa29d198
|
7
|
+
data.tar.gz: e74db64eb655bd469aba22ea94d8ef5f1ac00d973b5378e4283ea40c913ad84276d50f0d9903dc2a2562a6b6e6c6158e68ac95b43189e145e94f6c35dc6962fc
|
data/README.rdoc
CHANGED
@@ -16,20 +16,27 @@ Számok betűvel írva az I18n könyvtár segítségével.
|
|
16
16
|
|
17
17
|
== Supported Languages / Языки / Langues Supportées
|
18
18
|
|
19
|
-
* English
|
20
|
-
* Spanish
|
21
|
-
* Русский
|
22
|
-
* Français
|
23
|
-
* Українська
|
24
|
-
* Magyar
|
25
|
-
* Türkçe**
|
26
|
-
* Italiano**
|
27
|
-
* Nederlands**
|
28
|
-
* Swedish**
|
29
|
-
* English (British)**
|
19
|
+
* English [en]
|
20
|
+
* Spanish [es]
|
21
|
+
* Русский [ru]
|
22
|
+
* Français [fr]
|
23
|
+
* Українська [ua]
|
24
|
+
* Magyar [hu]
|
25
|
+
* Türkçe** [tr]
|
26
|
+
* Italiano** [it]
|
27
|
+
* Nederlands** [nl]
|
28
|
+
* Swedish** [se]
|
29
|
+
* English (British)** [en-GB]
|
30
30
|
|
31
31
|
** Experimental
|
32
32
|
|
33
|
+
* {[en-AU], [en-CA], [en-IN], [en-US]}*** => [en]
|
34
|
+
* {[es-419], [es-AR], [es-CL], [es-CO], [es-MX], [es-PE], [es-VE]}*** => [es]
|
35
|
+
* {[fr-CA], [fr-CH]}*** => [fr]
|
36
|
+
* {[it-CH]}*** => [it]
|
37
|
+
|
38
|
+
*** Aliases
|
39
|
+
|
33
40
|
== Examples / Примеры / Exemples
|
34
41
|
|
35
42
|
I18n.with_locale(:en) { 42.to_words }
|
@@ -8,11 +8,15 @@ module NumbersAndWords
|
|
8
8
|
|
9
9
|
def to_words options = {}
|
10
10
|
validate_figure_array!
|
11
|
-
Strategies.figures_converter.new(self, options).run
|
11
|
+
local_language { Strategies.figures_converter.new(self, options).run }
|
12
12
|
end
|
13
13
|
|
14
14
|
def reverse
|
15
15
|
super.to_figures
|
16
16
|
end
|
17
|
+
|
18
|
+
def local_language
|
19
|
+
::I18n.with_locale(I18n.local_language) { yield }
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
@@ -5,7 +5,11 @@ module NumbersAndWords
|
|
5
5
|
class WordsArray < Array
|
6
6
|
|
7
7
|
def join options = {}
|
8
|
-
Strategies.array_joiner.new(self.to_a, options).run
|
8
|
+
local_language { Strategies.array_joiner.new(self.to_a, options).run }
|
9
|
+
end
|
10
|
+
|
11
|
+
def local_language
|
12
|
+
::I18n.with_locale(I18n.local_language) { yield }
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -5,6 +5,27 @@ module NumbersAndWords
|
|
5
5
|
module I18n
|
6
6
|
extend self
|
7
7
|
|
8
|
+
def languages
|
9
|
+
@languages ||= (locale_files.map { |path| path.split(/[\/.]/)[-2].to_sym })
|
10
|
+
end
|
11
|
+
|
12
|
+
def local_language locale = ::I18n.locale
|
13
|
+
if languages.include?(locale)
|
14
|
+
locale
|
15
|
+
else
|
16
|
+
locale = locale.to_s.scan(/\w+/).first.to_sym
|
17
|
+
languages.include?(locale) ? locale : raise('Language not supported')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def language_class_name
|
22
|
+
::I18n.locale.to_s.titleize.gsub ' ', ''
|
23
|
+
end
|
24
|
+
|
25
|
+
def locale_files
|
26
|
+
files 'locales', '*.*'
|
27
|
+
end
|
28
|
+
|
8
29
|
def files directory, ext
|
9
30
|
Dir[File.join File.dirname(__FILE__), "i18n/#{directory}", "**/#{ext}"]
|
10
31
|
end
|
@@ -3,22 +3,10 @@ module NumbersAndWords
|
|
3
3
|
module Initialization
|
4
4
|
extend self
|
5
5
|
|
6
|
-
attr_accessor :languages
|
7
|
-
|
8
6
|
def init
|
9
|
-
locale_files.each { |locale_file| ::I18n.load_path << locale_file}
|
7
|
+
I18n.locale_files.each { |locale_file| ::I18n.load_path << locale_file}
|
10
8
|
NumbersAndWords::I18n::Pluralization.init
|
11
9
|
end
|
12
|
-
|
13
|
-
def languages
|
14
|
-
@languages ||= (locale_files.map{|path| path.split(/[\/.]/)[-2]})
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def locale_files
|
20
|
-
I18n.files 'locales', '*.*'
|
21
|
-
end
|
22
10
|
end
|
23
11
|
end
|
24
12
|
end
|
@@ -14,11 +14,7 @@ module NumbersAndWords
|
|
14
14
|
module Languages
|
15
15
|
class << self
|
16
16
|
def factory strategy
|
17
|
-
"#{name}::#{language_class_name}".constantize.new strategy
|
18
|
-
end
|
19
|
-
|
20
|
-
def language_class_name
|
21
|
-
::I18n.locale.to_s.titleize.gsub ' ', ''
|
17
|
+
"#{name}::#{I18n.language_class_name}".constantize.new strategy
|
22
18
|
end
|
23
19
|
end
|
24
20
|
end
|
@@ -27,11 +27,7 @@ module NumbersAndWords
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def decorator_class_name method_name
|
30
|
-
"#{name}::#{language_class_name}::#{method_name.to_s.camelcase}"
|
31
|
-
end
|
32
|
-
|
33
|
-
def language_class_name
|
34
|
-
::I18n.locale.to_s.titleize.gsub ' ', ''
|
30
|
+
"#{name}::#{I18n.language_class_name}::#{method_name.to_s.camelcase}"
|
35
31
|
end
|
36
32
|
end
|
37
33
|
end
|
@@ -27,11 +27,7 @@ module NumbersAndWords
|
|
27
27
|
module Languages
|
28
28
|
class << self
|
29
29
|
def factory strategy
|
30
|
-
"#{name}::#{language_class_name}".constantize.new strategy
|
31
|
-
end
|
32
|
-
|
33
|
-
def language_class_name
|
34
|
-
::I18n.locale.to_s.titleize.gsub ' ', ''
|
30
|
+
"#{name}::#{I18n.language_class_name}".constantize.new strategy
|
35
31
|
end
|
36
32
|
end
|
37
33
|
end
|
@@ -25,11 +25,7 @@ module NumbersAndWords
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def proxy_class_name method_name
|
28
|
-
"#{module_name}::#{language_class_name}::#{method_name.to_s.camelcase}"
|
29
|
-
end
|
30
|
-
|
31
|
-
def language_class_name
|
32
|
-
::I18n.locale.to_s.titleize.gsub ' ', ''
|
28
|
+
"#{module_name}::#{I18n.language_class_name}::#{method_name.to_s.camelcase}"
|
33
29
|
end
|
34
30
|
|
35
31
|
def module_name
|
@@ -19,11 +19,7 @@ module NumbersAndWords
|
|
19
19
|
module Translations
|
20
20
|
class << self
|
21
21
|
def factory
|
22
|
-
"#{name}::#{language_class_name}".constantize.new
|
23
|
-
end
|
24
|
-
|
25
|
-
def language_class_name
|
26
|
-
::I18n.locale.to_s.titleize.gsub ' ', ''
|
22
|
+
"#{name}::#{I18n.language_class_name}".constantize.new
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numbers_and_words
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.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-
|
11
|
+
date: 2013-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: jeweler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Convert numbers to words using I18N.
|
@@ -203,12 +203,12 @@ require_paths:
|
|
203
203
|
- lib
|
204
204
|
required_ruby_version: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
|
-
- -
|
206
|
+
- - '>='
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
210
|
requirements:
|
211
|
-
- -
|
211
|
+
- - '>='
|
212
212
|
- !ruby/object:Gem::Version
|
213
213
|
version: '0'
|
214
214
|
requirements: []
|