translation_panel 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/Gemfile.lock +0 -2
- data/README.rdoc +16 -1
- data/VERSION +1 -1
- data/{spec/app/app/controllers/admin → app/controllers/translations}/translations_controller.rb +3 -2
- data/config/routes.rb +5 -0
- data/lib/translation_panel/engine.rb +11 -0
- data/lib/translation_panel/filter.rb +3 -3
- data/lib/translation_panel.rb +1 -24
- data/spec/app/app/controllers/application_controller.rb +1 -3
- data/spec/app/config/routes.rb +0 -4
- data/spec/translation_panel_spec.rb +0 -18
- data/translation_panel.gemspec +5 -6
- metadata +12 -21
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -112,7 +112,6 @@ GEM
|
|
112
112
|
hike (~> 1.0)
|
113
113
|
rack (~> 1.0)
|
114
114
|
tilt (!= 1.3.0, ~> 1.1)
|
115
|
-
sqlite3 (1.3.3)
|
116
115
|
thor (0.14.6)
|
117
116
|
tilt (1.3.2)
|
118
117
|
treetop (1.4.9)
|
@@ -131,5 +130,4 @@ DEPENDENCIES
|
|
131
130
|
rails (>= 3.1.0.rc4)
|
132
131
|
redis
|
133
132
|
rspec-rails (>= 2.0.0.beta)
|
134
|
-
sqlite3
|
135
133
|
yajl-ruby
|
data/README.rdoc
CHANGED
@@ -1,3 +1,18 @@
|
|
1
1
|
= TranslationPanel
|
2
2
|
|
3
|
-
|
3
|
+
Using with Redis:
|
4
|
+
|
5
|
+
1. Run redis-server
|
6
|
+
|
7
|
+
2. Set up redis connection settings and register RedisTranslator::Backend as
|
8
|
+
i18n backend in initializers:
|
9
|
+
require 'redis_translator'
|
10
|
+
I18n.backend = RedisTranslator::Backend.new(Redis.new)
|
11
|
+
# or in chain with another backend
|
12
|
+
|
13
|
+
3. Create predicate method +translation_panel?+ in ApplicationController,
|
14
|
+
define in it, when panel can be shown and when translates can be saved. By
|
15
|
+
default always.
|
16
|
+
def translation_panel?
|
17
|
+
params[:translator].present?
|
18
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/{spec/app/app/controllers/admin → app/controllers/translations}/translations_controller.rb
RENAMED
@@ -1,7 +1,8 @@
|
|
1
|
-
class
|
1
|
+
class Translations::TranslationsController < ApplicationController
|
2
|
+
# TODO: add security restrictions
|
2
3
|
def new
|
3
4
|
params[:value] = nil if params[:value].empty?
|
4
|
-
I18n.backend.store_translations params[:locale], {params[:key] => params[:value]}, :escape => false
|
5
|
+
I18n.backend.store_translations params[:locale], {params[:key] => params[:value]}, {:escape => false}
|
5
6
|
render :text => 'ok', :content_type => "text/plain"
|
6
7
|
end
|
7
8
|
end
|
data/config/routes.rb
ADDED
@@ -2,9 +2,9 @@ module TranslationPanel
|
|
2
2
|
class Filter
|
3
3
|
include ActionView::Helpers::TagHelper
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
@save_url =
|
7
|
-
@condition =
|
5
|
+
def initialize
|
6
|
+
@save_url = '/translations/translations/new'
|
7
|
+
@condition = :translation_panel?
|
8
8
|
end
|
9
9
|
|
10
10
|
def before(controller)
|
data/lib/translation_panel.rb
CHANGED
@@ -1,29 +1,6 @@
|
|
1
1
|
require "translation_panel/filter"
|
2
2
|
require "translation_panel/redis_backend"
|
3
|
-
|
4
|
-
# Using with Redis:
|
5
|
-
# 1. Run redis-server
|
6
|
-
# 2. Set up redis connection settings and register RedisTranslator::Backend as
|
7
|
-
# i18n backend in initializers:
|
8
|
-
# require 'redis_translator'
|
9
|
-
# I18n.backend = RedisTranslator::Backend.new(Redis.new)
|
10
|
-
# # or in chain with another backend
|
11
|
-
# 3. Create action which receive translation pair and saves it. Don't forget to
|
12
|
-
# create route for GET-requests to this action
|
13
|
-
# class Admin::TranslationsController < ApplicationController
|
14
|
-
# def new
|
15
|
-
# I18n.backend.store_translations params[:locale], {params[:key] => params[:value]},
|
16
|
-
# :escape => false
|
17
|
-
# render :text => 'ok', :content_type => "text/plain"
|
18
|
-
# end
|
19
|
-
# end
|
20
|
-
# 4. Create around filter for actions, where needed to show TranslationPanel
|
21
|
-
# frontend panel. Initializator receives path for action and condition.
|
22
|
-
# around_filter TranslationPanel::Filter.new('/admin/translations/new', :show_panel?)
|
23
|
-
# 5. TranslationPanel's javascript and stylesheet can be customized by copying
|
24
|
-
# necessary files from +app/assets+ to app's +vendor/assets+. It can be done
|
25
|
-
# automatically by run:
|
26
|
-
# $ rails generate redis_translator:install
|
3
|
+
require "translation_panel/engine"
|
27
4
|
|
28
5
|
module TranslationPanel
|
29
6
|
class << self
|
@@ -1,10 +1,8 @@
|
|
1
1
|
class ApplicationController < ActionController::Base
|
2
2
|
protect_from_forgery
|
3
|
-
respond_to :html
|
4
|
-
around_filter TranslationPanel::Filter.new('/admin/translations/new', :show_translator?)
|
5
3
|
|
6
4
|
protected
|
7
|
-
def
|
5
|
+
def translation_panel?
|
8
6
|
params[:translator].present?
|
9
7
|
end
|
10
8
|
end
|
data/spec/app/config/routes.rb
CHANGED
@@ -51,21 +51,3 @@ describe HomeController, :type => :controller do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
55
|
-
describe Admin::TranslationsController, :type => :controller do
|
56
|
-
describe "new" do
|
57
|
-
before :all do
|
58
|
-
I18n.backend.store.flushdb
|
59
|
-
end
|
60
|
-
|
61
|
-
it "saves new translation" do
|
62
|
-
get :new, :locale => "ru", :key => "some.key", :value => "some_value"
|
63
|
-
I18n.t("some.key", :locale => "ru").should == "some_value"
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'updates existing translation' do
|
67
|
-
get :new, :locale => "ru", :key => "some.key", :value => "other_value"
|
68
|
-
I18n.t("some.key", :locale => "ru").should == "other_value"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/translation_panel.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{translation_panel}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Mik-die}]
|
12
|
-
s.date = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-20}
|
13
13
|
s.description = %q{I18n backend, based on redis, with frontend panel for translations}
|
14
14
|
s.email = %q{MikDiet@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,12 +26,14 @@ Gem::Specification.new do |s|
|
|
26
26
|
"VERSION",
|
27
27
|
"app/assets/javascripts/translation_panel.js.coffee",
|
28
28
|
"app/assets/stylesheets/translation_panel.css.scss",
|
29
|
+
"app/controllers/translations/translations_controller.rb",
|
30
|
+
"config/routes.rb",
|
29
31
|
"lib/generators/translation_panel/install_generator.rb",
|
30
32
|
"lib/translation_panel.rb",
|
33
|
+
"lib/translation_panel/engine.rb",
|
31
34
|
"lib/translation_panel/filter.rb",
|
32
35
|
"lib/translation_panel/redis_backend.rb",
|
33
36
|
"spec/app/.gitignore",
|
34
|
-
"spec/app/app/controllers/admin/translations_controller.rb",
|
35
37
|
"spec/app/app/controllers/application_controller.rb",
|
36
38
|
"spec/app/app/controllers/home_controller.rb",
|
37
39
|
"spec/app/app/views/home/index.html.erb",
|
@@ -68,7 +70,6 @@ Gem::Specification.new do |s|
|
|
68
70
|
s.add_runtime_dependency(%q<rails>, [">= 3.1.0.rc4"])
|
69
71
|
s.add_runtime_dependency(%q<redis>, [">= 0"])
|
70
72
|
s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
|
71
|
-
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
72
73
|
s.add_development_dependency(%q<capybara>, [">= 0.4.0"])
|
73
74
|
s.add_development_dependency(%q<rspec-rails>, [">= 2.0.0.beta"])
|
74
75
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
@@ -76,7 +77,6 @@ Gem::Specification.new do |s|
|
|
76
77
|
s.add_dependency(%q<rails>, [">= 3.1.0.rc4"])
|
77
78
|
s.add_dependency(%q<redis>, [">= 0"])
|
78
79
|
s.add_dependency(%q<yajl-ruby>, [">= 0"])
|
79
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
80
80
|
s.add_dependency(%q<capybara>, [">= 0.4.0"])
|
81
81
|
s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta"])
|
82
82
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
@@ -85,7 +85,6 @@ Gem::Specification.new do |s|
|
|
85
85
|
s.add_dependency(%q<rails>, [">= 3.1.0.rc4"])
|
86
86
|
s.add_dependency(%q<redis>, [">= 0"])
|
87
87
|
s.add_dependency(%q<yajl-ruby>, [">= 0"])
|
88
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
89
88
|
s.add_dependency(%q<capybara>, [">= 0.4.0"])
|
90
89
|
s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta"])
|
91
90
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: translation_panel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mik-die
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-20 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -45,20 +45,9 @@ dependencies:
|
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: *id003
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: sqlite3
|
50
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: "0"
|
56
|
-
type: :development
|
57
|
-
prerelease: false
|
58
|
-
version_requirements: *id004
|
59
48
|
- !ruby/object:Gem::Dependency
|
60
49
|
name: capybara
|
61
|
-
requirement: &
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
62
51
|
none: false
|
63
52
|
requirements:
|
64
53
|
- - ">="
|
@@ -66,10 +55,10 @@ dependencies:
|
|
66
55
|
version: 0.4.0
|
67
56
|
type: :development
|
68
57
|
prerelease: false
|
69
|
-
version_requirements: *
|
58
|
+
version_requirements: *id004
|
70
59
|
- !ruby/object:Gem::Dependency
|
71
60
|
name: rspec-rails
|
72
|
-
requirement: &
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
73
62
|
none: false
|
74
63
|
requirements:
|
75
64
|
- - ">="
|
@@ -77,10 +66,10 @@ dependencies:
|
|
77
66
|
version: 2.0.0.beta
|
78
67
|
type: :development
|
79
68
|
prerelease: false
|
80
|
-
version_requirements: *
|
69
|
+
version_requirements: *id005
|
81
70
|
- !ruby/object:Gem::Dependency
|
82
71
|
name: jeweler
|
83
|
-
requirement: &
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
84
73
|
none: false
|
85
74
|
requirements:
|
86
75
|
- - ">="
|
@@ -88,7 +77,7 @@ dependencies:
|
|
88
77
|
version: "0"
|
89
78
|
type: :development
|
90
79
|
prerelease: false
|
91
|
-
version_requirements: *
|
80
|
+
version_requirements: *id006
|
92
81
|
description: I18n backend, based on redis, with frontend panel for translations
|
93
82
|
email: MikDiet@gmail.com
|
94
83
|
executables: []
|
@@ -108,12 +97,14 @@ files:
|
|
108
97
|
- VERSION
|
109
98
|
- app/assets/javascripts/translation_panel.js.coffee
|
110
99
|
- app/assets/stylesheets/translation_panel.css.scss
|
100
|
+
- app/controllers/translations/translations_controller.rb
|
101
|
+
- config/routes.rb
|
111
102
|
- lib/generators/translation_panel/install_generator.rb
|
112
103
|
- lib/translation_panel.rb
|
104
|
+
- lib/translation_panel/engine.rb
|
113
105
|
- lib/translation_panel/filter.rb
|
114
106
|
- lib/translation_panel/redis_backend.rb
|
115
107
|
- spec/app/.gitignore
|
116
|
-
- spec/app/app/controllers/admin/translations_controller.rb
|
117
108
|
- spec/app/app/controllers/application_controller.rb
|
118
109
|
- spec/app/app/controllers/home_controller.rb
|
119
110
|
- spec/app/app/views/home/index.html.erb
|
@@ -149,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
140
|
requirements:
|
150
141
|
- - ">="
|
151
142
|
- !ruby/object:Gem::Version
|
152
|
-
hash:
|
143
|
+
hash: 766588307
|
153
144
|
segments:
|
154
145
|
- 0
|
155
146
|
version: "0"
|