interpret 1.0.2 → 1.1.0
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.
- data/app/assets/javascripts/interpret.js +3 -0
- data/app/controllers/interpret/base_controller.rb +8 -2
- data/app/controllers/interpret/translations_controller.rb +10 -6
- data/{lib/interpret/helpers.rb → app/helpers/interpret/interpret_helper.rb} +2 -6
- data/app/models/interpret/translation.rb +1 -0
- data/app/views/layouts/interpret/interpret.html.erb +63 -52
- data/config/routes.rb +2 -0
- data/interpret.gemspec +1 -0
- data/lib/interpret/engine.rb +1 -1
- data/lib/interpret/version.rb +1 -1
- data/lib/interpret.rb +0 -4
- data/test_app/app/controllers/application_controller.rb +1 -1
- data/test_app/config/initializers/interpret.rb +0 -1
- metadata +19 -4
- data/app/views/layouts/interpret/interpret_base.html.erb +0 -14
@@ -1,18 +1,24 @@
|
|
1
|
-
class Interpret::BaseController <
|
1
|
+
class Interpret::BaseController < Interpret.parent_controller.classify.constantize
|
2
2
|
before_filter :set_locale
|
3
3
|
before_filter { authorize! :use, :interpret }
|
4
4
|
before_filter :check_authorized_language
|
5
5
|
layout 'interpret/interpret'
|
6
|
+
helper Interpret::InterpretHelper
|
6
7
|
|
7
8
|
protected
|
8
9
|
def current_interpret_user
|
9
|
-
|
10
|
+
send(Interpret.current_user)
|
10
11
|
end
|
11
12
|
|
12
13
|
def current_ability
|
13
14
|
@current_ability ||= Interpret.ability.new(current_interpret_user)
|
14
15
|
end
|
15
16
|
|
17
|
+
def default_url_options(options = {})
|
18
|
+
options.merge({:locale => I18n.locale})
|
19
|
+
end
|
20
|
+
|
21
|
+
|
16
22
|
private
|
17
23
|
def set_locale
|
18
24
|
I18n.locale = params[:locale] if params[:locale]
|
@@ -3,6 +3,10 @@ module Interpret
|
|
3
3
|
before_filter :get_tree, :only => :index
|
4
4
|
authorize_resource :class => "Interpret::Translation"
|
5
5
|
|
6
|
+
def welcome
|
7
|
+
redirect_to root_url
|
8
|
+
end
|
9
|
+
|
6
10
|
def index
|
7
11
|
key = params[:key]
|
8
12
|
t = Interpret::Translation.arel_table
|
@@ -36,15 +40,15 @@ module Interpret
|
|
36
40
|
respond_to do |format|
|
37
41
|
if @translation.update_attributes(params[:translation].presence || params[:interpret_translation])
|
38
42
|
msg = ""
|
39
|
-
msg << "By [#{
|
43
|
+
msg << "By [#{current_interpret_user}]. " if current_interpret_user
|
40
44
|
msg << "Locale: [#{@translation.locale}], key: [#{@translation.key}]. The translation has been changed from [#{old_value}] to [#{@translation.value}]"
|
41
45
|
Interpret.logger.info msg
|
42
46
|
|
43
|
-
format.html { redirect_to
|
47
|
+
format.html { redirect_to :back }
|
44
48
|
format.xml { head :ok }
|
45
49
|
format.json { head :ok }
|
46
50
|
else
|
47
|
-
format.html { redirect_to
|
51
|
+
format.html { redirect_to :back }
|
48
52
|
format.xml { render :xml => @translation.errors, :status => :unprocessable_entity }
|
49
53
|
format.json { render :status => :unprocessable_entity }
|
50
54
|
end
|
@@ -56,10 +60,10 @@ module Interpret
|
|
56
60
|
|
57
61
|
if @translation.save
|
58
62
|
flash[:notice] = "New translation created for #{@translation.key}"
|
59
|
-
redirect_to
|
63
|
+
redirect_to :back
|
60
64
|
else
|
61
65
|
flash[:alert] = "Error when creating a new translation"
|
62
|
-
redirect_to
|
66
|
+
redirect_to :back
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
@@ -68,7 +72,7 @@ module Interpret
|
|
68
72
|
|
69
73
|
@translation.destroy
|
70
74
|
flash[:notice] = "Translation #{@translation.key} destroyed."
|
71
|
-
redirect_to
|
75
|
+
redirect_to :back
|
72
76
|
end
|
73
77
|
|
74
78
|
private
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Interpret
|
2
|
-
module
|
2
|
+
module InterpretHelper
|
3
3
|
# Generates the html tree from the given keys
|
4
4
|
def interpret_show_tree(tree, origin_keys)
|
5
5
|
tree = tree.first[1]
|
@@ -17,11 +17,6 @@ module Interpret
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def interpret_parent_layout(layout)
|
21
|
-
@view_flow.set(:layout, self.output_buffer)
|
22
|
-
self.output_buffer = render(:file => "layouts/#{layout}")
|
23
|
-
end
|
24
|
-
|
25
20
|
private
|
26
21
|
|
27
22
|
def build_tree(hash, origin_keys = "", prev_key = "")
|
@@ -44,3 +39,4 @@ module Interpret
|
|
44
39
|
end
|
45
40
|
end
|
46
41
|
end
|
42
|
+
|
@@ -1,55 +1,66 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
| <%= link_to "Search", search_path, :class => controller_name == "search" ? "current" : ""%>
|
16
|
-
<% end%>
|
17
|
-
|
18
|
-
<% if can? :read, :missing_translations%>
|
19
|
-
| <%= link_to "Missing translations", missing_translations_path, :class => controller_name == "missing_translations" && action_name == "index" ? "current" : ""%>
|
20
|
-
<% end%>
|
21
|
-
|
22
|
-
<% if can? :read, :stale_translations%>
|
23
|
-
| <%= link_to "Stale translations", stale_translations_path, :class => controller_name == "missing_translations" && action_name == "stale" ? "current" : ""%>
|
24
|
-
<% end%>
|
25
|
-
|
26
|
-
<% if can? :read, :blank_translations%>
|
27
|
-
| <%= link_to "Blank translations", blank_translations_path, :class => controller_name == "missing_translations" && action_name == "blank" ? "current" : ""%>
|
28
|
-
<% end%>
|
29
|
-
|
30
|
-
<% if can? :read, :unused_translations%>
|
31
|
-
| <%= link_to "Unused translations", unused_translations_path, :class => controller_name == "missing_translations" && action_name == "unused" ? "current" : ""%>
|
32
|
-
<% end%>
|
33
|
-
<hr />
|
34
|
-
</div>
|
35
|
-
<div class="menu grid_4" id='languages_nav'>
|
36
|
-
Languages:
|
37
|
-
<% Interpret::Translation.available_locales.each do |locale| %>
|
38
|
-
<% next unless can? :use, :"interpret_in_#{locale}" %>
|
39
|
-
<% opts = {:locale => locale} %>
|
40
|
-
<% opts[:key] = params[:key] if params[:key] %>
|
41
|
-
<% opts[:value] = params[:value] if params[:value] %>
|
42
|
-
<%= link_to locale, opts %>
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= yield :title %></title>
|
5
|
+
<%= stylesheet_link_tag "interpret_style" %>
|
6
|
+
<%= javascript_include_tag "interpret" %>
|
7
|
+
<%= csrf_meta_tag %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div id="interpret_container">
|
11
|
+
<% if flash.any? %>
|
12
|
+
<div class="interpret_flash grid_16 <%= flash.keys.first %>">
|
13
|
+
<%= flash[:notice] || flash[:alert] %>
|
14
|
+
</div>
|
43
15
|
<% end %>
|
44
|
-
<
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
16
|
+
<div class="menu grid_12">
|
17
|
+
<%= link_to "Overview", root_path, :class => controller_name == "translations" && action_name == "index" ? "current" : "" %>
|
18
|
+
|
19
|
+
<% if can? :use, :tools%>
|
20
|
+
| <%= link_to "Tools", tools_path, :class => controller_name == "tools" ? "current" : "" %>
|
21
|
+
<% end%>
|
22
|
+
|
23
|
+
<% if can? :use, :search%>
|
24
|
+
| <%= link_to "Search", search_path, :class => controller_name == "search" ? "current" : ""%>
|
25
|
+
<% end%>
|
26
|
+
|
27
|
+
<% if can? :read, :missing_translations%>
|
28
|
+
| <%= link_to "Missing translations", missing_translations_path, :class => controller_name == "missing_translations" && action_name == "index" ? "current" : ""%>
|
29
|
+
<% end%>
|
30
|
+
|
31
|
+
<% if can? :read, :stale_translations%>
|
32
|
+
| <%= link_to "Stale translations", stale_translations_path, :class => controller_name == "missing_translations" && action_name == "stale" ? "current" : ""%>
|
33
|
+
<% end%>
|
34
|
+
|
35
|
+
<% if can? :read, :blank_translations%>
|
36
|
+
| <%= link_to "Blank translations", blank_translations_path, :class => controller_name == "missing_translations" && action_name == "blank" ? "current" : ""%>
|
37
|
+
<% end%>
|
38
|
+
|
39
|
+
<% if can? :read, :unused_translations%>
|
40
|
+
| <%= link_to "Unused translations", unused_translations_path, :class => controller_name == "missing_translations" && action_name == "unused" ? "current" : ""%>
|
41
|
+
<% end%>
|
42
|
+
<hr />
|
43
|
+
</div>
|
44
|
+
<div class="menu grid_4" id='languages_nav'>
|
45
|
+
Languages:
|
46
|
+
<% Interpret::Translation.available_locales.each do |locale| %>
|
47
|
+
<% next unless can? :use, :"interpret_in_#{locale}" %>
|
48
|
+
<% opts = {:locale => locale} %>
|
49
|
+
<% opts[:key] = params[:key] if params[:key] %>
|
50
|
+
<% opts[:value] = params[:value] if params[:value] %>
|
51
|
+
<%= link_to locale, opts %>
|
52
|
+
<% end %>
|
53
|
+
<hr />
|
54
|
+
</div>
|
55
|
+
<div class="clearfix"></div>
|
56
|
+
<div id="sidebar" class="grid_3">
|
57
|
+
<%= yield :sidebar %>
|
58
|
+
</div>
|
59
|
+
<div id="main" class="grid_13">
|
60
|
+
<%= yield %>
|
61
|
+
</div>
|
52
62
|
</div>
|
53
|
-
</div>
|
54
63
|
|
55
|
-
|
64
|
+
</body>
|
65
|
+
</html>
|
66
|
+
|
data/config/routes.rb
CHANGED
data/interpret.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_dependency "best_in_place", "~> 1.0"
|
27
27
|
s.add_dependency "lazyhash", ">= 0.1.1"
|
28
28
|
s.add_dependency "cancan", "~> 1.6.0"
|
29
|
+
s.add_dependency "jquery-rails"
|
29
30
|
|
30
31
|
s.add_development_dependency "rspec-rails", "~> 2.5"
|
31
32
|
s.add_development_dependency "capybara", "~> 1.0.1"
|
data/lib/interpret/engine.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'interpret/logger'
|
2
|
-
require 'interpret/helpers'
|
3
2
|
|
4
3
|
module Interpret
|
5
4
|
class Engine < Rails::Engine
|
6
5
|
isolate_namespace Interpret
|
6
|
+
engine_name "interpret"
|
7
7
|
|
8
8
|
initializer "interpret.register_i18n_active_record_backend" do |app|
|
9
9
|
app.config.after_initialize do
|
data/lib/interpret/version.rb
CHANGED
data/lib/interpret.rb
CHANGED
@@ -9,14 +9,12 @@ module Interpret
|
|
9
9
|
mattr_accessor :parent_controller
|
10
10
|
mattr_accessor :registered_envs
|
11
11
|
mattr_accessor :current_user
|
12
|
-
mattr_accessor :layout
|
13
12
|
mattr_accessor :soft
|
14
13
|
mattr_accessor :black_list
|
15
14
|
mattr_accessor :ability
|
16
15
|
|
17
16
|
@@parent_controller = "application_controller"
|
18
17
|
@@registered_envs = [:production, :staging]
|
19
|
-
@@layout = "interpret_base"
|
20
18
|
@@soft = true
|
21
19
|
@@black_list = []
|
22
20
|
@@current_user = "current_user"
|
@@ -44,5 +42,3 @@ module Interpret
|
|
44
42
|
end
|
45
43
|
|
46
44
|
require 'interpret/engine' if defined? Rails
|
47
|
-
|
48
|
-
ActionView::Base.send(:include, Interpret::InterpretHelpers)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interpret
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -123,6 +123,22 @@ dependencies:
|
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 1.6.0
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: jquery-rails
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
126
142
|
- !ruby/object:Gem::Dependency
|
127
143
|
name: rspec-rails
|
128
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,6 +208,7 @@ files:
|
|
192
208
|
- app/controllers/interpret/search_controller.rb
|
193
209
|
- app/controllers/interpret/tools_controller.rb
|
194
210
|
- app/controllers/interpret/translations_controller.rb
|
211
|
+
- app/helpers/interpret/interpret_helper.rb
|
195
212
|
- app/models/interpret/ability.rb
|
196
213
|
- app/models/interpret/expiration_observer.rb
|
197
214
|
- app/models/interpret/translation.rb
|
@@ -207,14 +224,12 @@ files:
|
|
207
224
|
- app/views/interpret/translations/index.html.erb
|
208
225
|
- app/views/interpret/translations/new.html.erb
|
209
226
|
- app/views/layouts/interpret/interpret.html.erb
|
210
|
-
- app/views/layouts/interpret/interpret_base.html.erb
|
211
227
|
- config/environment.rb
|
212
228
|
- config/routes.rb
|
213
229
|
- db/migrate/20111108094329_create_translations.rb
|
214
230
|
- interpret.gemspec
|
215
231
|
- lib/interpret.rb
|
216
232
|
- lib/interpret/engine.rb
|
217
|
-
- lib/interpret/helpers.rb
|
218
233
|
- lib/interpret/logger.rb
|
219
234
|
- lib/interpret/version.rb
|
220
235
|
- lib/tasks/interpret.rake
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title><%= yield :title %></title>
|
5
|
-
<%= stylesheet_link_tag "interpret_style" %>
|
6
|
-
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" %>
|
7
|
-
<%= javascript_include_tag "best_in_place", "interpret" %>
|
8
|
-
<%= csrf_meta_tag %>
|
9
|
-
</head>
|
10
|
-
<body>
|
11
|
-
<%= yield %>
|
12
|
-
</body>
|
13
|
-
</html>
|
14
|
-
|