glib-web 3.11.0 → 3.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/glib/enum_helper.rb +5 -0
- data/app/models/concerns/glib/enum_humanization.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67a72ba29ae5a4a9d5d61d529db6ad2316af2fb2d76042ca7fda76b309b5dcba
|
4
|
+
data.tar.gz: c3e935f1d809ee9ce3ec3fa78bdf53250303192949909b12ebf8ac5f9f27f7b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 588dc4f17590880d8c0e6eaacf7f467a1db815a24e317d0d458449c7065d9dbd8ac77ddf7b621581a48992528306334d45439f8b9a1b7acaf4c4e42d53b72ba9
|
7
|
+
data.tar.gz: c1d4655e081970ad4739397ce2b0f221cb7a491757c9da532c433dd85245ba0a4b39e87164c00a2e83942e008c439298b76d528b7bd65cb93abf5b8b54ec089d
|
@@ -5,6 +5,11 @@ module Glib
|
|
5
5
|
keys ||= clazz.defined_enums[enum_name].keys
|
6
6
|
keys.map do |i|
|
7
7
|
text = clazz.glib_enum_humanize(enum_field, i)
|
8
|
+
|
9
|
+
if text.nil?
|
10
|
+
raise "activerecord.attributes.#{clazz.model_name.i18n_key}.#{enum_field.to_s.pluralize}.#{i}"
|
11
|
+
end
|
12
|
+
|
8
13
|
if include_hints
|
9
14
|
i18n_key = clazz.model_name.i18n_key
|
10
15
|
hint = I18n.t("dt_models.#{i18n_key}.#{enum_name.pluralize}.#{i}.hint")
|
@@ -19,11 +19,12 @@ module Glib
|
|
19
19
|
module ClassMethods
|
20
20
|
def glib_enum_humanize(enum_name, enum_value, default_translation = nil)
|
21
21
|
if enum_value
|
22
|
+
translation_key = "activerecord.attributes.#{model_name.i18n_key}.#{enum_name.to_s.pluralize}.#{enum_value}"
|
23
|
+
|
22
24
|
if default_translation.nil? && Rails.env.development?
|
23
|
-
|
24
|
-
I18n.t(i18n_key, raise: I18n::MissingTranslationData)
|
25
|
+
I18n.t(translation_key, raise: I18n::MissingTranslationData)
|
25
26
|
else
|
26
|
-
I18n.t(
|
27
|
+
I18n.t(translation_key, default: default_translation)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|