l10n 0.0.12 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/l10n.rb +3 -8
- data/lib/l10n/core_extensions/big_decimal_ext.rb +7 -10
- data/lib/l10n/core_extensions/numeric_ext.rb +14 -7
- data/lib/l10n/forms.rb +1 -1
- data/lib/l10n/version.rb +1 -1
- metadata +36 -54
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5ab27dbdb740c4220ad55fb7b9fc27ab5edf1d51
|
4
|
+
data.tar.gz: f7e40005e73373e64a6240bd729381223080b971
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 90f3081b3d195719668091d4f004990f98119ced1e7671e78f1a30d3635965be32010c729f80391a97f81fdd12dd0952c0d128098f697d445e0b632d6873faa9
|
7
|
+
data.tar.gz: 3b4f33bd868fbc3a0f9a69ec8184d6f821761cf31db80232c01e3c59f1e30fb8063661f45972e4f90f4184aeea0289b17429bf0286ad7f26dd00b4bd1356743d
|
data/lib/l10n.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'i18n'
|
2
|
+
require 'bigdecimal'
|
2
3
|
require 'action_view'
|
3
4
|
require 'action_dispatch'
|
4
5
|
require 'active_support/all'
|
@@ -17,7 +18,6 @@ files = Dir[File.join(File.dirname(__FILE__), 'locales/*.yml')]
|
|
17
18
|
I18n.load_path.concat(files)
|
18
19
|
|
19
20
|
module L10n
|
20
|
-
@number_helper = Object.new.tap { |obj| obj.extend ActionView::Helpers::NumberHelper }
|
21
21
|
|
22
22
|
class << self
|
23
23
|
|
@@ -41,13 +41,8 @@ module L10n
|
|
41
41
|
# i18n_available_locales.map { |i18n_locale| normalize_language_code(i18n_locale) }.uniq
|
42
42
|
#end
|
43
43
|
|
44
|
-
def
|
45
|
-
|
46
|
-
#defaults = { :separator => I18n.t('number.format.separator'),
|
47
|
-
# :delimiter => I18n.t('number.format.delimiter'),
|
48
|
-
# :precision => I18n.t('number.format.precision') }
|
49
|
-
#options.reverse_merge!(defaults)
|
50
|
-
@number_helper.number_with_precision(number, options)
|
44
|
+
def number_to_rounded(number, options = {})
|
45
|
+
ActiveSupport::NumberHelper.number_to_rounded(number, options)
|
51
46
|
end
|
52
47
|
|
53
48
|
private
|
@@ -1,23 +1,20 @@
|
|
1
|
-
require 'bigdecimal'
|
2
|
-
|
3
1
|
module L10n
|
4
2
|
module CoreExtensions
|
5
3
|
module BigDecimalExt
|
4
|
+
extend ActiveSupport::Concern
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
alias_method :to_formatted_s, :_l10n_to_formatted_s
|
12
|
-
end
|
6
|
+
included do
|
7
|
+
alias_method :_active_support_to_formatted_s, :to_formatted_s
|
8
|
+
alias_method :to_s, :_active_support_to_formatted_s
|
9
|
+
alias_method :to_formatted_s, :_l10n_to_formatted_s
|
13
10
|
end
|
14
11
|
|
15
12
|
def _l10n_to_formatted_s(*args)
|
16
|
-
L10n.
|
13
|
+
L10n.number_to_rounded(self, *args)
|
17
14
|
end
|
18
15
|
#
|
19
16
|
end
|
20
17
|
end
|
21
18
|
end
|
22
19
|
|
23
|
-
BigDecimal.
|
20
|
+
BigDecimal.class_eval { include L10n::CoreExtensions::BigDecimalExt }
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module L10n
|
2
2
|
module CoreExtensions
|
3
3
|
module NumericExt
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
alias_method :_active_support_to_formatted_s, :to_formatted_s
|
8
|
+
alias_method :to_formatted_s, :_l10n_to_formatted_s
|
7
9
|
end
|
8
|
-
|
10
|
+
|
9
11
|
module ClassMethods
|
10
12
|
def delocalize(value)
|
11
13
|
return value unless value.is_a?(String)
|
@@ -26,12 +28,17 @@ module L10n
|
|
26
28
|
Numeric.localize(self)
|
27
29
|
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
# Provide l10n signature
|
32
|
+
def _l10n_to_formatted_s(format = :rounded, options = nil)
|
33
|
+
if options.nil? && format.is_a?(Hash)
|
34
|
+
options = format
|
35
|
+
format = :rounded
|
36
|
+
end
|
37
|
+
_active_support_to_formatted_s(format, options || {})
|
31
38
|
end
|
32
39
|
|
33
40
|
end
|
34
41
|
end
|
35
42
|
end
|
36
43
|
|
37
|
-
Numeric.
|
44
|
+
Numeric.class_eval { include L10n::CoreExtensions::NumericExt }
|
data/lib/l10n/forms.rb
CHANGED
@@ -3,7 +3,7 @@ module L10n
|
|
3
3
|
module FormBuilder
|
4
4
|
|
5
5
|
def amount_field(field, options = {})
|
6
|
-
value = L10n.
|
6
|
+
value = L10n.number_to_rounded(object.send(field))
|
7
7
|
options[:value] = value
|
8
8
|
options[:class] = "#{options[:class]} amount_field"
|
9
9
|
text_field(field, options)
|
data/lib/l10n/version.rb
CHANGED
metadata
CHANGED
@@ -1,142 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: l10n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matthias Grosser
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: i18n
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0
|
19
|
+
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0
|
26
|
+
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: activerecord
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: '4.0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: '4.0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: activesupport
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
47
|
+
version: '4.0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
54
|
+
version: '4.0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: actionpack
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
61
|
+
version: '4.0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
68
|
+
version: '4.0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: sqlite3
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: debugger
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: simplecov
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - ">="
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: rake
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - ">="
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: 0.8.7
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - ">="
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: 0.8.7
|
142
125
|
description: I18n that roarrrs
|
@@ -145,14 +128,18 @@ executables: []
|
|
145
128
|
extensions: []
|
146
129
|
extra_rdoc_files: []
|
147
130
|
files:
|
131
|
+
- MIT-LICENSE
|
132
|
+
- README.md
|
133
|
+
- Rakefile
|
134
|
+
- lib/l10n.rb
|
148
135
|
- lib/l10n/column_translation.rb
|
136
|
+
- lib/l10n/core_extensions.rb
|
149
137
|
- lib/l10n/core_extensions/big_decimal_ext.rb
|
150
138
|
- lib/l10n/core_extensions/date_ext.rb
|
151
139
|
- lib/l10n/core_extensions/numeric_ext.rb
|
152
140
|
- lib/l10n/core_extensions/object_ext.rb
|
153
141
|
- lib/l10n/core_extensions/string_ext.rb
|
154
142
|
- lib/l10n/core_extensions/symbol_ext.rb
|
155
|
-
- lib/l10n/core_extensions.rb
|
156
143
|
- lib/l10n/forms.rb
|
157
144
|
- lib/l10n/i18n_extensions.rb
|
158
145
|
- lib/l10n/inflections.rb
|
@@ -160,34 +147,29 @@ files:
|
|
160
147
|
- lib/l10n/request.rb
|
161
148
|
- lib/l10n/translation_validator.rb
|
162
149
|
- lib/l10n/version.rb
|
163
|
-
- lib/l10n.rb
|
164
150
|
- lib/locales/de.yml
|
165
151
|
- lib/locales/en.yml
|
166
|
-
- MIT-LICENSE
|
167
|
-
- README.md
|
168
|
-
- Rakefile
|
169
152
|
homepage: http://rubygems.org/gems/l10n
|
170
153
|
licenses: []
|
154
|
+
metadata: {}
|
171
155
|
post_install_message:
|
172
156
|
rdoc_options: []
|
173
157
|
require_paths:
|
174
158
|
- lib
|
175
159
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
-
none: false
|
177
160
|
requirements:
|
178
|
-
- -
|
161
|
+
- - ">="
|
179
162
|
- !ruby/object:Gem::Version
|
180
163
|
version: '0'
|
181
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
-
none: false
|
183
165
|
requirements:
|
184
|
-
- -
|
166
|
+
- - ">="
|
185
167
|
- !ruby/object:Gem::Version
|
186
168
|
version: '0'
|
187
169
|
requirements: []
|
188
170
|
rubyforge_project:
|
189
|
-
rubygems_version:
|
171
|
+
rubygems_version: 2.2.0
|
190
172
|
signing_key:
|
191
|
-
specification_version:
|
173
|
+
specification_version: 4
|
192
174
|
summary: Extensions for Rails I18n
|
193
175
|
test_files: []
|