copycat 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -0
- data/config/routes.rb +1 -11
- data/lib/copycat/implementation.rb +12 -10
- data/lib/copycat/routes.rb +17 -0
- data/lib/copycat/simple.rb +1 -1
- data/lib/copycat/version.rb +1 -1
- data/lib/copycat.rb +1 -0
- data/spec/dummy/log/test.log +5664 -0
- data/spec/lib/copycat_spec.rb +1 -1
- metadata +5 -4
data/README.md
CHANGED
@@ -40,6 +40,18 @@ Since this process requires no code commits, non-developers can also 'deploy' co
|
|
40
40
|
|
41
41
|
You can also commit Copycat's YAML export, which is compatible with i18n, to your git repository.
|
42
42
|
|
43
|
+
## Routes ##
|
44
|
+
|
45
|
+
The default route to edit copy is '/copycat_translations'. This can be customized in the initializer.
|
46
|
+
|
47
|
+
The Copycat routes are configured automatically by the engine, after your Rails application's routes.rb file is run. This means that if your routes include a catchall route at the bottom, the Copycat route will be masked. In this case you can manually draw the Copycat routes prior to the catchall route with the following line in config/routes.rb:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
Rails.application.routes.draw do
|
51
|
+
Copycat.routes(self)
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
43
55
|
## Example ##
|
44
56
|
|
45
57
|
See an example application [here](https://github.com/Vermonster/copycat-demo).
|
data/config/routes.rb
CHANGED
@@ -1,13 +1,3 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
:as => 'copycat_translations',
|
4
|
-
:controller => 'copycat_translations',
|
5
|
-
:only => [:index, :edit, :update, :destroy] do
|
6
|
-
collection do
|
7
|
-
get 'help'
|
8
|
-
get 'import_export'
|
9
|
-
get 'download'
|
10
|
-
post 'upload'
|
11
|
-
end
|
12
|
-
end
|
2
|
+
Copycat.routes(self)
|
13
3
|
end
|
@@ -1,13 +1,15 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
module Copycat
|
2
|
+
module Implementation
|
3
|
+
# this method overrides part of the i18n gem, lib/i18n/backend/simple.rb
|
4
|
+
def lookup(locale, key, scope = [], options = {})
|
5
|
+
return super unless ActiveRecord::Base.connected? && CopycatTranslation.table_exists?
|
6
|
+
cct = CopycatTranslation.where(locale: locale, key: key).first
|
7
|
+
return cct.value if cct
|
8
|
+
value = super(locale, key, scope, options)
|
9
|
+
if value.is_a?(String) || value.nil?
|
10
|
+
CopycatTranslation.create(locale: locale, key: key, value: value)
|
11
|
+
end
|
12
|
+
value
|
10
13
|
end
|
11
|
-
value
|
12
14
|
end
|
13
15
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Copycat
|
2
|
+
def self.routes(mapper)
|
3
|
+
mapper.instance_eval do
|
4
|
+
resources Copycat.route,
|
5
|
+
:as => 'copycat_translations',
|
6
|
+
:controller => 'copycat_translations',
|
7
|
+
:only => [:index, :edit, :update, :destroy] do
|
8
|
+
collection do
|
9
|
+
get 'help'
|
10
|
+
get 'import_export'
|
11
|
+
get 'download'
|
12
|
+
post 'upload'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/copycat/simple.rb
CHANGED
data/lib/copycat/version.rb
CHANGED