rails_db_localize 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/app/models/rails_db_localize/translation.rb +2 -10
- data/lib/ext/active_record_ext.rb +1 -1
- data/lib/ext/controller_ext.rb +1 -1
- data/lib/rails_db_localize/railtie.rb +5 -0
- data/lib/rails_db_localize/version.rb +1 -1
- data/lib/rails_db_localize.rb +7 -3
- data/lib/tasks/rails_db_localize_tasks.rake +31 -11
- metadata +5 -150
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/javascripts/translatables.js +0 -2
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/assets/stylesheets/translatables.css +0 -4
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/controllers/translatables_controller.rb +0 -16
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/helpers/translatables_helper.rb +0 -2
- data/test/dummy/app/models/translatable.rb +0 -3
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/translatables/index.html.erb +0 -36
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -29
- data/test/dummy/config/application.rb +0 -26
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -41
- data/test/dummy/config/environments/production.rb +0 -79
- data/test/dummy/config/environments/test.rb +0 -42
- data/test/dummy/config/initializers/assets.rb +0 -11
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -59
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/config.ru +0 -4
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20150907053532_create_translation_table.rb +0 -5
- data/test/dummy/db/migrate/20150907053908_create_translatable.rb +0 -7
- data/test/dummy/db/schema.rb +0 -40
- data/test/dummy/lib/tasks/populate.rake +0 -11
- data/test/dummy/log/development.log +0 -12164
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/controllers/translatables_controller_test.rb +0 -7
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/3O2pqsT3ybnPUm6Gi7ErjmLeCBRRUWz4fMCvw-ibCB0.cache +0 -2
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -2
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/6qyNdZnWUudLJAOThY51h8UbkuubQ6d87qQokqr9_Io.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/9yOpc3M6o_Vd_0RjCLTe8PJNtWsWGrV4zdvCJgbMtvw.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ANeC_6Mk_I5aOnvx2d-aSzot3B_oq6NBEI2K_mJEnWM.cache +0 -1
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/BAArHgUaRCG_NHra3C0s9BRNUfg8e8yJC8Tw0wOKH-A.cache +0 -1
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/B_ZbUByps36PvVRYHSdlhwdAtP5-Zf3zVtDzL-IQNrQ.cache +0 -2
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Cg8aXWizze0m2o4NT5ZriA69UfhbMK2hDD1D0oPK1JI.cache +0 -1
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/DpdBg7WBC-mtsYWWSF3TjYyBBi-Evpi_ana2Hh_30LM.cache +0 -1
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ELlZNzycCi1-_hT_LCUVm1uUF65_XGNtAbDizvvphuA.cache +0 -1
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/EzYy4pCO7n17PL8udZ40Mjw8k09nEOwcWk4Oi-a_Hwg.cache +0 -1
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/NnJakuOJenyIjIygEryzdLDMdyyxVbseqRcdbkwnoAI.cache +0 -1
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/O4S1k7_Y87AttftaL1s29JQtwbK4syBxZMLzIVuu1vk.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -2
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/P3uTHiFsLRdy5tNIFjY3okQd6odvdpdGk6oogoFhoGk.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ZffU_0SbArG9GYeAowBJuJgaF1hVGbMNGeDIj9bqa9A.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/c8KYVj1rHA3NliflfWZWsyCpCQAFkHuDTGW0GGTL0Bo.cache +0 -1
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -2
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/iN2MkusZ4QURJ8-cxj-e7yLM4a1aqMS4VNwG63KkVZY.cache +0 -1
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/lCUSCqZNMlgdamWEpHVlaxIHvpPKRbmiI3DgkCQqQRQ.cache +0 -2
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/lZwz80GEq6cMAemaJYqRQdQbxAb92jM-0r0zq11lMxI.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -2
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/vvbyKzG93brAbyVrZ7Q2gGUXUgcsVmB6eDpz25kvPFg.cache +0 -1
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/znAAVScTWs7VUkicijSLxlPcvxUCnkiPoFshMXcE458.cache +0 -1
- data/test/rails_db_localize_test.rb +0 -7
- data/test/test_helper.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0855f92777523618d4335e741efb90b8bc5c2fe4
|
4
|
+
data.tar.gz: acede288df13e639afeb15c1fcbb3dbf3e82f2cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccc2b2021f288fff616c15fe2c074322dddc77548ac3ef50119091f0c8f1ddc5b56e27c2181addf58e87c09eb552c3af523f73f31358ae3c0376e63414cbe7c4
|
7
|
+
data.tar.gz: aad994566c29fa328fd035d3716f246e3de6adde4ce5e0c4c2375997e98119a7ff44bfa0538855c14688d52f29868cb1c96ae08c270a06247c1b2446c2d0abcd
|
data/README.md
CHANGED
@@ -121,6 +121,14 @@ Create two users with role translator with from/to_language "en/fr" and "fr/es".
|
|
121
121
|
|
122
122
|
# Changelog
|
123
123
|
|
124
|
+
## 0.3
|
125
|
+
|
126
|
+
* Fix issues inside the gem.
|
127
|
+
|
128
|
+
* Add the rake task rails_db_localize:delete_orphans
|
129
|
+
|
130
|
+
This task allow you to delete the old translations which not belongs to any model and/or belongs to a field/model which isn't existing anymore.
|
131
|
+
|
124
132
|
## 0.2
|
125
133
|
|
126
134
|
Add methods `having_translation`, `missing_translation` and `preload_translation`
|
@@ -11,12 +11,11 @@ class RailsDbLocalize::Translation < ActiveRecord::Base
|
|
11
11
|
|
12
12
|
validates :content, uniqueness: { scope: [:lang, :field, :resource_type, :resource_id] }
|
13
13
|
|
14
|
-
scope :
|
14
|
+
scope :for_language, lambda { |x| where(lang: x) }
|
15
|
+
scope :for_model, lambda { |m| where(resource_type: m.class, resource_id: m.id) }
|
15
16
|
|
16
17
|
before_validation :set_compound_key
|
17
18
|
|
18
|
-
|
19
|
-
|
20
19
|
def self.generate_ck resource_type, resource_id
|
21
20
|
hash_long = [resource_type.to_s.underscore, resource_id].join("|").chars.map(&:ord).inject(5381) do |h, v|
|
22
21
|
h = ((h<<5)+h)+v
|
@@ -26,13 +25,6 @@ class RailsDbLocalize::Translation < ActiveRecord::Base
|
|
26
25
|
hash_long & 0x7fffffff
|
27
26
|
end
|
28
27
|
|
29
|
-
|
30
|
-
def self.get_untranslated model, field, lang
|
31
|
-
model.where("id NOT IN (?)",
|
32
|
-
[-1, *RailsDbLocalize::Translation.where(resource_type: k.to_s, lang: lang, field: field).pluck(:resource_id).uniq]
|
33
|
-
)
|
34
|
-
end
|
35
|
-
|
36
28
|
private
|
37
29
|
def set_compound_key
|
38
30
|
self.compound_key = RailsDbLocalize::Translation.generate_ck(resource_type, resource_id)
|
@@ -6,7 +6,7 @@ class ActiveRecord::Base
|
|
6
6
|
unless @__rdbl_translations
|
7
7
|
@__rdbl_translations = true
|
8
8
|
# Register it mostly to remove the translations once you delete an object
|
9
|
-
self.has_many :translations, as: :resource, dependent: :destroy
|
9
|
+
self.has_many :translations, class_name: "RailsDbLocalize::Translation", as: :resource, dependent: :destroy
|
10
10
|
|
11
11
|
scope :__rails_db_translations_sub_query, lambda{ |lang|
|
12
12
|
ttable = RailsDbLocalize::Translation.arel_table.name
|
data/lib/ext/controller_ext.rb
CHANGED
@@ -6,7 +6,7 @@ class ActionController::Base
|
|
6
6
|
|
7
7
|
# Preload the translations string for all the collections.
|
8
8
|
# This allow to load all translation resources in only one SQL query.
|
9
|
-
# Take in consideration this will execute the request
|
9
|
+
# Take in consideration this will execute the request
|
10
10
|
def preload_translations_for *collections
|
11
11
|
RailsDbLocalize::TranslationCache.instance.prefetch_collections(*collections)
|
12
12
|
end
|
data/lib/rails_db_localize.rb
CHANGED
@@ -10,8 +10,8 @@ module RailsDbLocalize
|
|
10
10
|
|
11
11
|
def add_to_schema model, field
|
12
12
|
@schema ||= {}
|
13
|
-
@schema[model.to_s] ||= []
|
14
|
-
|
13
|
+
arr = (@schema[model.to_s] ||= [])
|
14
|
+
arr << field unless arr.index(field)
|
15
15
|
end
|
16
16
|
|
17
17
|
def load!
|
@@ -22,6 +22,10 @@ module RailsDbLocalize
|
|
22
22
|
ActiveSupport::Dependencies.autoload_once_paths.delete(path)
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
def gem_path
|
27
|
+
@gem_path ||= File.expand_path("..", File.dirname(__FILE__))
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
@@ -32,6 +36,6 @@ def __rdbl_require(*args)
|
|
32
36
|
end
|
33
37
|
|
34
38
|
__rdbl_require 'rails_db_localize/translation_cache'
|
39
|
+
__rdbl_require 'rails_db_localize/railtie'
|
35
40
|
__rdbl_require 'ext/active_record_ext', 'ext/controller_ext', 'ext/migration_ext'
|
36
|
-
|
37
41
|
RailsDbLocalize::load!
|
@@ -1,11 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
namespace :rails_db_localize do
|
2
|
+
desc "Remove the orphans in the translations"
|
3
|
+
task :delete_orphans => :environment do
|
4
|
+
|
5
|
+
# Preload all the models for building the schema.
|
6
|
+
# Only useful for development mode when the models are autoloaded.
|
7
|
+
RailsDbLocalize::Translation.group(:resource_type).pluck(:resource_type).each do |rt|
|
8
|
+
begin
|
9
|
+
rt.classify.constantize
|
10
|
+
rescue
|
11
|
+
puts "Cannot constantize `#{rt}`"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
#Now we have an updated schema,
|
16
|
+
# we can remove illegal keys and illegal ids
|
17
|
+
to_delete = RailsDbLocalize::Translation
|
18
|
+
.where("resource_type NOT IN (?)", [-1, *RailsDbLocalize.schema.keys])
|
19
|
+
|
20
|
+
RailsDbLocalize.schema.each do |klass, field_list|
|
21
|
+
klass = klass.classify.constantize
|
22
|
+
to_delete += RailsDbLocalize::Translation
|
23
|
+
.where("resource_type =? AND ( field NOT IN (?) OR resource_id NOT IN (?) )",
|
24
|
+
klass, [-1, *field_list],
|
25
|
+
klass.pluck(klass.primary_key))
|
26
|
+
end
|
27
|
+
|
28
|
+
puts "REMOVED ORPHANS: #{to_delete.count}"
|
29
|
+
to_delete.each(&:destroy)
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_db_localize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yacine PETITPREZ
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -96,82 +96,10 @@ files:
|
|
96
96
|
- lib/ext/controller_ext.rb
|
97
97
|
- lib/ext/migration_ext.rb
|
98
98
|
- lib/rails_db_localize.rb
|
99
|
+
- lib/rails_db_localize/railtie.rb
|
99
100
|
- lib/rails_db_localize/translation_cache.rb
|
100
101
|
- lib/rails_db_localize/version.rb
|
101
102
|
- lib/tasks/rails_db_localize_tasks.rake
|
102
|
-
- test/dummy/README.rdoc
|
103
|
-
- test/dummy/Rakefile
|
104
|
-
- test/dummy/app/assets/javascripts/application.js
|
105
|
-
- test/dummy/app/assets/javascripts/translatables.js
|
106
|
-
- test/dummy/app/assets/stylesheets/application.css
|
107
|
-
- test/dummy/app/assets/stylesheets/translatables.css
|
108
|
-
- test/dummy/app/controllers/application_controller.rb
|
109
|
-
- test/dummy/app/controllers/translatables_controller.rb
|
110
|
-
- test/dummy/app/helpers/application_helper.rb
|
111
|
-
- test/dummy/app/helpers/translatables_helper.rb
|
112
|
-
- test/dummy/app/models/translatable.rb
|
113
|
-
- test/dummy/app/views/layouts/application.html.erb
|
114
|
-
- test/dummy/app/views/translatables/index.html.erb
|
115
|
-
- test/dummy/bin/bundle
|
116
|
-
- test/dummy/bin/rails
|
117
|
-
- test/dummy/bin/rake
|
118
|
-
- test/dummy/bin/setup
|
119
|
-
- test/dummy/config.ru
|
120
|
-
- test/dummy/config/application.rb
|
121
|
-
- test/dummy/config/boot.rb
|
122
|
-
- test/dummy/config/database.yml
|
123
|
-
- test/dummy/config/environment.rb
|
124
|
-
- test/dummy/config/environments/development.rb
|
125
|
-
- test/dummy/config/environments/production.rb
|
126
|
-
- test/dummy/config/environments/test.rb
|
127
|
-
- test/dummy/config/initializers/assets.rb
|
128
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
129
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
130
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
131
|
-
- test/dummy/config/initializers/inflections.rb
|
132
|
-
- test/dummy/config/initializers/mime_types.rb
|
133
|
-
- test/dummy/config/initializers/session_store.rb
|
134
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
135
|
-
- test/dummy/config/locales/en.yml
|
136
|
-
- test/dummy/config/routes.rb
|
137
|
-
- test/dummy/config/secrets.yml
|
138
|
-
- test/dummy/db/development.sqlite3
|
139
|
-
- test/dummy/db/migrate/20150907053532_create_translation_table.rb
|
140
|
-
- test/dummy/db/migrate/20150907053908_create_translatable.rb
|
141
|
-
- test/dummy/db/schema.rb
|
142
|
-
- test/dummy/lib/tasks/populate.rake
|
143
|
-
- test/dummy/log/development.log
|
144
|
-
- test/dummy/public/404.html
|
145
|
-
- test/dummy/public/422.html
|
146
|
-
- test/dummy/public/500.html
|
147
|
-
- test/dummy/public/favicon.ico
|
148
|
-
- test/dummy/test/controllers/translatables_controller_test.rb
|
149
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/3O2pqsT3ybnPUm6Gi7ErjmLeCBRRUWz4fMCvw-ibCB0.cache
|
150
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache
|
151
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/6qyNdZnWUudLJAOThY51h8UbkuubQ6d87qQokqr9_Io.cache
|
152
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/9yOpc3M6o_Vd_0RjCLTe8PJNtWsWGrV4zdvCJgbMtvw.cache
|
153
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/ANeC_6Mk_I5aOnvx2d-aSzot3B_oq6NBEI2K_mJEnWM.cache
|
154
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/BAArHgUaRCG_NHra3C0s9BRNUfg8e8yJC8Tw0wOKH-A.cache
|
155
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/B_ZbUByps36PvVRYHSdlhwdAtP5-Zf3zVtDzL-IQNrQ.cache
|
156
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/Cg8aXWizze0m2o4NT5ZriA69UfhbMK2hDD1D0oPK1JI.cache
|
157
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/DpdBg7WBC-mtsYWWSF3TjYyBBi-Evpi_ana2Hh_30LM.cache
|
158
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/ELlZNzycCi1-_hT_LCUVm1uUF65_XGNtAbDizvvphuA.cache
|
159
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/EzYy4pCO7n17PL8udZ40Mjw8k09nEOwcWk4Oi-a_Hwg.cache
|
160
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/NnJakuOJenyIjIygEryzdLDMdyyxVbseqRcdbkwnoAI.cache
|
161
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/O4S1k7_Y87AttftaL1s29JQtwbK4syBxZMLzIVuu1vk.cache
|
162
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache
|
163
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/P3uTHiFsLRdy5tNIFjY3okQd6odvdpdGk6oogoFhoGk.cache
|
164
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/ZffU_0SbArG9GYeAowBJuJgaF1hVGbMNGeDIj9bqa9A.cache
|
165
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/c8KYVj1rHA3NliflfWZWsyCpCQAFkHuDTGW0GGTL0Bo.cache
|
166
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache
|
167
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/iN2MkusZ4QURJ8-cxj-e7yLM4a1aqMS4VNwG63KkVZY.cache
|
168
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/lCUSCqZNMlgdamWEpHVlaxIHvpPKRbmiI3DgkCQqQRQ.cache
|
169
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/lZwz80GEq6cMAemaJYqRQdQbxAb92jM-0r0zq11lMxI.cache
|
170
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache
|
171
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/vvbyKzG93brAbyVrZ7Q2gGUXUgcsVmB6eDpz25kvPFg.cache
|
172
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/znAAVScTWs7VUkicijSLxlPcvxUCnkiPoFshMXcE458.cache
|
173
|
-
- test/rails_db_localize_test.rb
|
174
|
-
- test/test_helper.rb
|
175
103
|
homepage: https://github.com/anykeyh/rails_db_localize
|
176
104
|
licenses:
|
177
105
|
- APACHE 2.0
|
@@ -195,78 +123,5 @@ rubyforge_project:
|
|
195
123
|
rubygems_version: 2.4.8
|
196
124
|
signing_key:
|
197
125
|
specification_version: 4
|
198
|
-
summary:
|
199
|
-
test_files:
|
200
|
-
- test/dummy/app/assets/javascripts/application.js
|
201
|
-
- test/dummy/app/assets/javascripts/translatables.js
|
202
|
-
- test/dummy/app/assets/stylesheets/application.css
|
203
|
-
- test/dummy/app/assets/stylesheets/translatables.css
|
204
|
-
- test/dummy/app/controllers/application_controller.rb
|
205
|
-
- test/dummy/app/controllers/translatables_controller.rb
|
206
|
-
- test/dummy/app/helpers/application_helper.rb
|
207
|
-
- test/dummy/app/helpers/translatables_helper.rb
|
208
|
-
- test/dummy/app/models/translatable.rb
|
209
|
-
- test/dummy/app/views/layouts/application.html.erb
|
210
|
-
- test/dummy/app/views/translatables/index.html.erb
|
211
|
-
- test/dummy/bin/bundle
|
212
|
-
- test/dummy/bin/rails
|
213
|
-
- test/dummy/bin/rake
|
214
|
-
- test/dummy/bin/setup
|
215
|
-
- test/dummy/config/application.rb
|
216
|
-
- test/dummy/config/boot.rb
|
217
|
-
- test/dummy/config/database.yml
|
218
|
-
- test/dummy/config/environment.rb
|
219
|
-
- test/dummy/config/environments/development.rb
|
220
|
-
- test/dummy/config/environments/production.rb
|
221
|
-
- test/dummy/config/environments/test.rb
|
222
|
-
- test/dummy/config/initializers/assets.rb
|
223
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
224
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
225
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
226
|
-
- test/dummy/config/initializers/inflections.rb
|
227
|
-
- test/dummy/config/initializers/mime_types.rb
|
228
|
-
- test/dummy/config/initializers/session_store.rb
|
229
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
230
|
-
- test/dummy/config/locales/en.yml
|
231
|
-
- test/dummy/config/routes.rb
|
232
|
-
- test/dummy/config/secrets.yml
|
233
|
-
- test/dummy/config.ru
|
234
|
-
- test/dummy/db/development.sqlite3
|
235
|
-
- test/dummy/db/migrate/20150907053532_create_translation_table.rb
|
236
|
-
- test/dummy/db/migrate/20150907053908_create_translatable.rb
|
237
|
-
- test/dummy/db/schema.rb
|
238
|
-
- test/dummy/lib/tasks/populate.rake
|
239
|
-
- test/dummy/log/development.log
|
240
|
-
- test/dummy/public/404.html
|
241
|
-
- test/dummy/public/422.html
|
242
|
-
- test/dummy/public/500.html
|
243
|
-
- test/dummy/public/favicon.ico
|
244
|
-
- test/dummy/Rakefile
|
245
|
-
- test/dummy/README.rdoc
|
246
|
-
- test/dummy/test/controllers/translatables_controller_test.rb
|
247
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/3O2pqsT3ybnPUm6Gi7ErjmLeCBRRUWz4fMCvw-ibCB0.cache
|
248
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache
|
249
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/6qyNdZnWUudLJAOThY51h8UbkuubQ6d87qQokqr9_Io.cache
|
250
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/9yOpc3M6o_Vd_0RjCLTe8PJNtWsWGrV4zdvCJgbMtvw.cache
|
251
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/ANeC_6Mk_I5aOnvx2d-aSzot3B_oq6NBEI2K_mJEnWM.cache
|
252
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/B_ZbUByps36PvVRYHSdlhwdAtP5-Zf3zVtDzL-IQNrQ.cache
|
253
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/BAArHgUaRCG_NHra3C0s9BRNUfg8e8yJC8Tw0wOKH-A.cache
|
254
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/c8KYVj1rHA3NliflfWZWsyCpCQAFkHuDTGW0GGTL0Bo.cache
|
255
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/Cg8aXWizze0m2o4NT5ZriA69UfhbMK2hDD1D0oPK1JI.cache
|
256
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/DpdBg7WBC-mtsYWWSF3TjYyBBi-Evpi_ana2Hh_30LM.cache
|
257
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/ELlZNzycCi1-_hT_LCUVm1uUF65_XGNtAbDizvvphuA.cache
|
258
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/EzYy4pCO7n17PL8udZ40Mjw8k09nEOwcWk4Oi-a_Hwg.cache
|
259
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache
|
260
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/iN2MkusZ4QURJ8-cxj-e7yLM4a1aqMS4VNwG63KkVZY.cache
|
261
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/lCUSCqZNMlgdamWEpHVlaxIHvpPKRbmiI3DgkCQqQRQ.cache
|
262
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/lZwz80GEq6cMAemaJYqRQdQbxAb92jM-0r0zq11lMxI.cache
|
263
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/NnJakuOJenyIjIygEryzdLDMdyyxVbseqRcdbkwnoAI.cache
|
264
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/O4S1k7_Y87AttftaL1s29JQtwbK4syBxZMLzIVuu1vk.cache
|
265
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache
|
266
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/P3uTHiFsLRdy5tNIFjY3okQd6odvdpdGk6oogoFhoGk.cache
|
267
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache
|
268
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/vvbyKzG93brAbyVrZ7Q2gGUXUgcsVmB6eDpz25kvPFg.cache
|
269
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/ZffU_0SbArG9GYeAowBJuJgaF1hVGbMNGeDIj9bqa9A.cache
|
270
|
-
- test/dummy/tmp/cache/assets/development/sprockets/v3.0/znAAVScTWs7VUkicijSLxlPcvxUCnkiPoFshMXcE458.cache
|
271
|
-
- test/rails_db_localize_test.rb
|
272
|
-
- test/test_helper.rb
|
126
|
+
summary: Manage database translations without any pain.
|
127
|
+
test_files: []
|
data/test/dummy/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
-
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
-
* file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class TranslatablesController < ApplicationController
|
2
|
-
def index
|
3
|
-
@translatables = Translatable.all
|
4
|
-
preload_translations_for(@translatables)
|
5
|
-
end
|
6
|
-
|
7
|
-
def set_tr
|
8
|
-
require 'faker'
|
9
|
-
|
10
|
-
@translatable = Translatable.find(params[:id])
|
11
|
-
@translatable.name_translated = Faker::Lorem.paragraph, params[:lang]
|
12
|
-
@translatable.save!
|
13
|
-
|
14
|
-
redirect_to "/"
|
15
|
-
end
|
16
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Dummy</title>
|
5
|
-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
-
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
@@ -1,36 +0,0 @@
|
|
1
|
-
<div>
|
2
|
-
<h1>Test Translatable</h1>
|
3
|
-
<h2>Schema:</h2>
|
4
|
-
<pre>
|
5
|
-
<%= RailsDbLocalize::schema.inspect %>
|
6
|
-
</pre>
|
7
|
-
<h2>TR Table:</h2>
|
8
|
-
<pre><%= RailsDbLocalize::Translation.all.pluck(:id, :compound_key, :field, :lang, :content).map{|x| x.inspect}.join("\n") %></pre>
|
9
|
-
<h2>Cache info:</h2>
|
10
|
-
<pre><%= RailsDbLocalize::TranslationCache.instance.cache %></pre>
|
11
|
-
<h2>Table info:</h2>
|
12
|
-
<table>
|
13
|
-
<thead>
|
14
|
-
<th>ID</th>
|
15
|
-
<th>Name</th>
|
16
|
-
<th>TR EN</th>
|
17
|
-
<th>TR ES</th>
|
18
|
-
<th>TR FR</th>
|
19
|
-
<th>Actions</th>
|
20
|
-
</thead>
|
21
|
-
<% @translatables.each do |t| %>
|
22
|
-
<tr>
|
23
|
-
<td><%= t.id %></td>
|
24
|
-
<td><%= t.name %></td>
|
25
|
-
<td><%= t.name_translated %></td>
|
26
|
-
<td><%= t.name_translated(:es) %></td>
|
27
|
-
<td><%= t.name_translated(:fr) %></td>
|
28
|
-
<td>
|
29
|
-
<a href="/set_tr/<%=t.id%>/en">GEN EN</a>
|
30
|
-
<a href="/set_tr/<%=t.id%>/es">GEN ES</a>
|
31
|
-
<a href="/set_tr/<%=t.id%>/fr">GEN FR</a>
|
32
|
-
</td>
|
33
|
-
</tr>
|
34
|
-
<% end %>
|
35
|
-
</table>
|
36
|
-
</div>
|
data/test/dummy/bin/bundle
DELETED
data/test/dummy/bin/rails
DELETED
data/test/dummy/bin/rake
DELETED
data/test/dummy/bin/setup
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
# path to your application root.
|
5
|
-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
-
|
7
|
-
Dir.chdir APP_ROOT do
|
8
|
-
# This script is a starting point to setup your application.
|
9
|
-
# Add necessary setup steps to this file:
|
10
|
-
|
11
|
-
puts "== Installing dependencies =="
|
12
|
-
system "gem install bundler --conservative"
|
13
|
-
system "bundle check || bundle install"
|
14
|
-
|
15
|
-
# puts "\n== Copying sample files =="
|
16
|
-
# unless File.exist?("config/database.yml")
|
17
|
-
# system "cp config/database.yml.sample config/database.yml"
|
18
|
-
# end
|
19
|
-
|
20
|
-
puts "\n== Preparing database =="
|
21
|
-
system "bin/rake db:setup"
|
22
|
-
|
23
|
-
puts "\n== Removing old logs and tempfiles =="
|
24
|
-
system "rm -f log/*"
|
25
|
-
system "rm -rf tmp/cache"
|
26
|
-
|
27
|
-
puts "\n== Restarting application server =="
|
28
|
-
system "touch tmp/restart.txt"
|
29
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
require 'rails/all'
|
4
|
-
|
5
|
-
Bundler.require(*Rails.groups)
|
6
|
-
require "rails_db_localize"
|
7
|
-
|
8
|
-
module Dummy
|
9
|
-
class Application < Rails::Application
|
10
|
-
# Settings in config/environments/* take precedence over those specified here.
|
11
|
-
# Application configuration should go into files in config/initializers
|
12
|
-
# -- all .rb files in that directory are automatically loaded.
|
13
|
-
|
14
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
-
|
18
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
-
# config.i18n.default_locale = :de
|
21
|
-
|
22
|
-
# Do not swallow errors in after_commit/after_rollback callbacks.
|
23
|
-
config.active_record.raise_in_transactional_callbacks = true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
data/test/dummy/config/boot.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# SQLite version 3.x
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem 'sqlite3'
|
6
|
-
#
|
7
|
-
default: &default
|
8
|
-
adapter: sqlite3
|
9
|
-
pool: 5
|
10
|
-
timeout: 5000
|
11
|
-
|
12
|
-
development:
|
13
|
-
<<: *default
|
14
|
-
database: db/development.sqlite3
|
15
|
-
|
16
|
-
# Warning: The database defined as "test" will be erased and
|
17
|
-
# re-generated from your development database when you run "rake".
|
18
|
-
# Do not set this db to the same as development or production.
|
19
|
-
test:
|
20
|
-
<<: *default
|
21
|
-
database: db/test.sqlite3
|
22
|
-
|
23
|
-
production:
|
24
|
-
<<: *default
|
25
|
-
database: db/production.sqlite3
|