para-i18n 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 519170473917cd23758ec9b9f02cc359aff46d30
|
4
|
+
data.tar.gz: 94de0b38416dd8e7ec05a107e100a0960ca1d310
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26b8fe3d2c87bb01feaba7681cf1ddff6d8caee96e5451becca1e2f4716532c2ce8e97423eb7c10ccead868b3056046dc04a5f2e97e3272dace8b3ca14d73d49
|
7
|
+
data.tar.gz: cdaa0acf5582e760d741d687f4ddb89ce7dbe7069dbeed85d8acceec114872d14f6e2b29403abecb82bafd2264f8ecfd2aa41a963671cb5f7b672ca5791dce10
|
@@ -2,6 +2,8 @@
|
|
2
2
|
= target_locale_select
|
3
3
|
|
4
4
|
= form.fieldset do
|
5
|
+
= I18n.with_locale(@target_locale) { form.input :_disabled_for_locale, as: :boolean, label: t("para.i18n.disabled_for_locale") }
|
6
|
+
|
5
7
|
- translated_model_fields_for(resource.class).each do |field|
|
6
8
|
= form.input field.field_name, as: :i18n, locale: @target_locale
|
7
9
|
|
data/lib/para/i18n/fallbacks.rb
CHANGED
data/lib/para/i18n/model.rb
CHANGED
@@ -9,7 +9,7 @@ module Para
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def read_translated_attribute(field, locale = ::I18n.locale)
|
12
|
-
return read_plain_or_store_attribute(field) if locale == ::I18n.default_locale
|
12
|
+
return read_plain_or_store_attribute(field) if locale == ::I18n.default_locale && field != :_disabled_for_locale
|
13
13
|
|
14
14
|
if model_translations[locale.to_s]
|
15
15
|
if (translation = model_translations[locale.to_s][field.to_s])
|
@@ -24,7 +24,7 @@ module Para
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def write_translated_attribute field, value, locale = ::I18n.locale
|
27
|
-
return write_plain_or_store_attribute(field, value) if locale == ::I18n.default_locale
|
27
|
+
return write_plain_or_store_attribute(field, value) if locale == ::I18n.default_locale && field != :_disabled_for_locale
|
28
28
|
|
29
29
|
# did not us ||= here to fix first assignation.
|
30
30
|
# Did not investigate on why ||= does not work
|
@@ -49,6 +49,10 @@ module Para
|
|
49
49
|
end.with_indifferent_access
|
50
50
|
end
|
51
51
|
|
52
|
+
def disabled_for_locale?
|
53
|
+
self.class.translates? && _disabled_for_locale
|
54
|
+
end
|
55
|
+
|
52
56
|
private
|
53
57
|
|
54
58
|
def read_plain_or_store_attribute(field)
|
@@ -103,6 +107,14 @@ module Para
|
|
103
107
|
write_translated_attribute(field, value)
|
104
108
|
end
|
105
109
|
end
|
110
|
+
|
111
|
+
define_method(:_disabled_for_locale) do
|
112
|
+
read_translated_attribute(:_disabled_for_locale) == "1"
|
113
|
+
end
|
114
|
+
|
115
|
+
define_method(:_disabled_for_locale=) do |value|
|
116
|
+
write_translated_attribute(:_disabled_for_locale, value)
|
117
|
+
end
|
106
118
|
end
|
107
119
|
|
108
120
|
def translates?
|
data/lib/para/i18n/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: para-i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valentin Ballestrino
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: para
|