smooth_operator 1.10.17 → 1.10.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/smooth_operator/model_schema.rb +4 -1
- data/lib/smooth_operator/translation.rb +11 -4
- data/lib/smooth_operator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmQ3ZWNiNWFhZGZiNWYyOGJiZmQ5Y2VlNjEyNTc4MzRlYzNiMzE2MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWVlNzhiNWZhNjFlYWJlY2Q3YzY3MDM2NTZmYmJkZGMwMGM3YzIyZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OThjMTlhZTA3MmY1ZDNjZjZmZTRiNmZiMDZlZDgxOTVhMGM0YzFlNTBiZTMw
|
10
|
+
MzBmNzZhOWI4NDgyYTBlZWFkNzUxNDUyNjA4MjQ4NjE2MzU0OTkwN2ViN2Uy
|
11
|
+
MDIwMDM4YzRiNmJiOTEyMjgxMDE5MTRjODJkMmRjN2I3NWMxYmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmFiNjRhYzkxNWQ4ZTFkOTM0OGEyMTUzZjE3ZjE2ZjNmMTdjNzE5OGRjYjBi
|
14
|
+
MDM5NGZmYTIxMGUyOGFkMGIyYWRhZTcyNzY0MWNmZDhjZWU4NjY5ZTUzMTlh
|
15
|
+
OGNiNTRjZDQyZGZmZWI3YWQxZTgzZTZlY2M2MDM5YWY2MjgxZGI=
|
@@ -71,7 +71,10 @@ module SmoothOperator
|
|
71
71
|
namespace ||= self.parents.detect do |n|
|
72
72
|
n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
|
+
ActiveModel::Name.new(self, namespace, @_model_name).tap do |model_name|
|
76
|
+
def model_name.human(options = {}); @klass.send(:_translate, "models.#{i18n_key}", options); end
|
77
|
+
end
|
75
78
|
end
|
76
79
|
end
|
77
80
|
|
@@ -3,16 +3,23 @@ module SmoothOperator
|
|
3
3
|
module Translation
|
4
4
|
|
5
5
|
def human_attribute_name(attribute_key_name, options = {})
|
6
|
+
_translate("attributes.#{model_name.i18n_key}.#{attribute_key_name}", options = {})
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
private ###################### PRIVATE #########################
|
11
|
+
|
12
|
+
def _translate(namespace = '', options = {})
|
6
13
|
no_translation = "-- no translation --"
|
7
14
|
|
8
|
-
defaults = ["smooth_operator
|
9
|
-
defaults << "activerecord
|
15
|
+
defaults = ["smooth_operator.#{namespace}".to_sym]
|
16
|
+
defaults << "activerecord.#{namespace}".to_sym
|
10
17
|
defaults << options[:default] if options[:default]
|
11
18
|
defaults.flatten!
|
12
19
|
defaults << no_translation
|
13
|
-
options[:count] ||= 1
|
14
20
|
|
15
|
-
|
21
|
+
options = { count: 1, default: defaults }.merge!(options.except(:default))
|
22
|
+
I18n.translate(defaults.shift, options)
|
16
23
|
end
|
17
24
|
|
18
25
|
end
|