ecm_translations2 3.0.0 → 4.0.0

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: afe29eecd98a2979449084f1e16d976feddd13ab
4
- data.tar.gz: 51c4b5cefd682a86115a2276966013e2c7565410
3
+ metadata.gz: 508b95882e69978a35a8fee867943335ec292dc4
4
+ data.tar.gz: 1230f1ce1c4c91b18db744e65d23631be9ed6b3f
5
5
  SHA512:
6
- metadata.gz: ceb3d18ad2111776b3ac7f59cab725385aea2047419542dc86c531c0ec2ab85e5e0f9c2d20c46f6f018fc15cda82ba814ca3c665b1318dde374aa83272108984
7
- data.tar.gz: 10150bd58bc41f6304da2c0046bf10560c269865e8062ab404ab7a643960bab94820353d23dd1f21b353362a523d708c799e648cc0ad1fc0cf5cf68fb46f1f53
6
+ metadata.gz: 4abf79290bbcf20cef492ee37b662b8e51d47e65b69f09d531d970f11d6aebfed62863c08c22c03ca661092c7631336f72971b48c7b1a05c5ac23ec515ef0da0
7
+ data.tar.gz: c03f107e80aa09f6413ffb779a45beb62821373dde40edfe734616bb34c5232330c065c34ca58692a0dc5e73035a3c14a5b239f9b3dc755193f2a26486f90997
@@ -1,6 +1,5 @@
1
1
  module Ecm::Translations
2
2
  class Translation < ActiveRecord::Base
3
-
4
3
  # scopes
5
4
  scope :not_translated, -> { where(value: nil) }
6
5
  scope :is_proc, -> { where(is_proc: true) }
@@ -1,10 +1,10 @@
1
1
  module Ecm::Translations
2
2
  class ImportTranslationsService
3
-
4
3
  class TranslationInFileSystem
5
4
  attr_accessor :key, :locale, :raw_key, :value
6
5
  def initialize(raw_key, value)
7
- @raw_key, @value = raw_key, value
6
+ @raw_key = raw_key
7
+ @value = value
8
8
  end
9
9
 
10
10
  def human
@@ -12,11 +12,11 @@ module Ecm::Translations
12
12
  end
13
13
 
14
14
  def key
15
- @raw_key.split(".").drop(1).join(".")
15
+ @raw_key.split('.').drop(1).join('.')
16
16
  end
17
17
 
18
18
  def locale
19
- @raw_key.split(".").first
19
+ @raw_key.split('.').first
20
20
  end
21
21
 
22
22
  def to_translation_attributes_hash
@@ -34,7 +34,7 @@ module Ecm::Translations
34
34
  end
35
35
 
36
36
  def initialize(options = {})
37
- options.reverse_merge!({ translations: load_translations_from_backends })
37
+ options.reverse_merge!(translations: load_translations_from_backends)
38
38
  @source_translations = options[:translations]
39
39
  end
40
40
 
@@ -67,7 +67,7 @@ module Ecm::Translations
67
67
  end
68
68
 
69
69
  if I18n.backend.respond_to?(:backends)
70
- return I18n.backend.backends.reject{ |backend| backend.class.name == 'I18n::Backend::ActiveRecord' }.collect do |backend|
70
+ return I18n.backend.backends.reject { |backend| backend.class.name == 'I18n::Backend::ActiveRecord' }.collect do |backend|
71
71
  backend.send(:init_translations) unless backend.initialized?
72
72
  backend.send(:translations)
73
73
  end.reduce({}, :merge)
@@ -80,15 +80,15 @@ module Ecm::Translations
80
80
  # end.reduce({}, :merge)
81
81
  # end
82
82
 
83
- def self.to_dotted_hash(hash, recursive_key = "")
83
+ def self.to_dotted_hash(hash, recursive_key = '')
84
84
  hash.each_with_object({}) do |(k, v), ret|
85
85
  key = recursive_key + k.to_s
86
86
  if v.is_a? Hash
87
- ret.merge! to_dotted_hash(v, key + ".")
87
+ ret.merge! to_dotted_hash(v, key + '.')
88
88
  else
89
89
  ret[key] = v
90
90
  end
91
91
  end
92
92
  end
93
93
  end
94
- end
94
+ end
@@ -6,7 +6,7 @@ end
6
6
 
7
7
  if I18n::Backend::ActiveRecord::Translation.table_exists?
8
8
  backends = [I18n::Backend::ActiveRecord.new, I18n.backend]
9
-
9
+
10
10
  I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize)
11
11
  I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Flatten)
12
12
 
@@ -15,4 +15,4 @@ if I18n::Backend::ActiveRecord::Translation.table_exists?
15
15
  else
16
16
  I18n.backend = I18n::Backend::Chain.new(*backends.reverse)
17
17
  end
18
- end
18
+ end
@@ -5,12 +5,6 @@ module Ecm
5
5
  g.test_framework :rspec, fixture: false
6
6
  g.fixture_replacement :factory_girl, dir: 'spec/factories'
7
7
  end
8
-
9
- initializer :ecm_translations_engine do
10
- ActiveAdmin.setup do |config|
11
- config.load_paths << File.join(root, 'app/admin')
12
- end
13
- end if Gem::Specification.find_all_by_name('activeadmin').any?
14
8
  end
15
9
  end
16
10
  end
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module Translations
3
- VERSION = '3.0.0'
3
+ VERSION = '4.0.0'
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ Ecm::Translations.configure do |config|
2
2
  # Whether to prefer translations from the database or not. If set to true,
3
3
  # translations coming from the database will override translations in yaml
4
4
  # files.
5
- #
5
+ #
6
6
  # Default: config.prefer_database_translations = true
7
7
  config.prefer_database_translations = true
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_translations2
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-09 00:00:00.000000000 Z
11
+ date: 2016-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -108,34 +108,6 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: devise
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: activeadmin
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
111
  - !ruby/object:Gem::Dependency
140
112
  name: sass-rails
141
113
  requirement: !ruby/object:Gem::Requirement
@@ -300,7 +272,6 @@ files:
300
272
  - MIT-LICENSE
301
273
  - README.rdoc
302
274
  - Rakefile
303
- - app/admin/ecm_translations_translations.rb
304
275
  - app/models/ecm/translations/translation.rb
305
276
  - app/services/ecm/translations/import_translations_service.rb
306
277
  - config/initializers/i18n_backend.rb
@@ -1,55 +0,0 @@
1
- ActiveAdmin.register Ecm::Translations::Translation do
2
- menu parent: proc { I18n.t('activeadmin.menu.ecm.translations') }.call
3
-
4
- permit_params :interpolations,
5
- :is_proc,
6
- :key,
7
- :locale,
8
- :value
9
-
10
- scope :all, default: true
11
- I18n.available_locales.each do |locale|
12
- scope(locale) { |translation| translation.where(locale: locale) }
13
- end
14
-
15
- form do |f|
16
- f.inputs do
17
- f.input :locale, collection: I18n.available_locales.collect { |locale| [locale, locale] }
18
- f.input :key
19
- f.input :value
20
- f.input :interpolations
21
- f.input :is_proc
22
- end
23
-
24
- f.actions
25
- end
26
-
27
- index do
28
- selectable_column
29
-
30
- column :id
31
- column :locale
32
- column :key
33
- column :value
34
- column :interpolations
35
- column :is_proc
36
- column :created_at
37
- column :updated_at
38
-
39
- actions
40
- end
41
-
42
- show do
43
- attributes_table do
44
- row :id
45
- row :locale
46
- row :key
47
- row :value
48
- row :interpolations
49
- row :is_proc
50
- row :created_at
51
- row :updated_at
52
- end
53
- active_admin_comments
54
- end
55
- end if Gem::Specification.find_all_by_name('activeadmin').any?