para-i18n 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44cf27378535862d1697fb584e5f6b7d3956ca48
4
- data.tar.gz: 10f6ca9a330dbc47a8501090cf94233c360db243
3
+ metadata.gz: 519170473917cd23758ec9b9f02cc359aff46d30
4
+ data.tar.gz: 94de0b38416dd8e7ec05a107e100a0960ca1d310
5
5
  SHA512:
6
- metadata.gz: 51ed0eab8beb33f6caae6e48b03e83c41b13537f3006abd543ff6c3d42fcc827fdce3c39eee4f425b118968305417183d7f3645379b246d57a7dfde3acfed452
7
- data.tar.gz: 435e13e852a2f9628a8bb2297d1d46a6d0258c01921bc140164c2a68ff9751fdf56e6761cbf9b07de2ca8f413075755fa6fee99958f460a659ec248d9daebf38
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
 
@@ -4,3 +4,4 @@ fr:
4
4
  translate: "Traduire"
5
5
  translation: "Traduction"
6
6
  choose_locale: "Traduire en :"
7
+ disabled_for_locale: "Masquer pour la langue en cours"
@@ -6,7 +6,7 @@ module Para
6
6
 
7
7
  if (fallbacks = ::I18n.fallbacks[locale]) && fallbacks.length > 1
8
8
  fallbacks[1]
9
- else
9
+ elsif locale != ::I18n.default_locale
10
10
  ::I18n.default_locale
11
11
  end
12
12
  end
@@ -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?
@@ -1,5 +1,5 @@
1
1
  module Para
2
2
  module I18n
3
- VERSION = "0.3.3"
3
+ VERSION = "0.3.4"
4
4
  end
5
5
  end
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.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-05-06 00:00:00.000000000 Z
11
+ date: 2019-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: para