interpret 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/.gitignore +2 -4
  2. data/Gemfile +2 -3
  3. data/README.md +1 -10
  4. data/{public/stylesheets → app/assets/images}/folder.png +0 -0
  5. data/{public → app/assets}/javascripts/interpret.js +0 -0
  6. data/{public/stylesheets/interpret_style.css → app/assets/stylesheets/interpret_style.css.erb} +1 -1
  7. data/app/controllers/interpret/base_controller.rb +1 -1
  8. data/app/controllers/interpret/search_controller.rb +8 -2
  9. data/app/controllers/interpret/tools_controller.rb +5 -5
  10. data/app/controllers/interpret/translations_controller.rb +59 -69
  11. data/app/models/interpret/translation.rb +1 -0
  12. data/app/views/interpret/missing_translations/blank.html.erb +1 -1
  13. data/app/views/interpret/missing_translations/index.html.erb +1 -1
  14. data/app/views/interpret/missing_translations/stale.html.erb +2 -2
  15. data/app/views/interpret/search/_blank_search.html.erb +1 -1
  16. data/app/views/interpret/search/_filled_search.html.erb +1 -1
  17. data/app/views/interpret/tools/index.html.erb +2 -2
  18. data/app/views/interpret/translations/_listing.html.erb +3 -3
  19. data/app/views/interpret/translations/new.html.erb +2 -2
  20. data/app/views/layouts/interpret/interpret.html.erb +55 -0
  21. data/app/views/layouts/{interpret_base.html.erb → interpret/interpret_base.html.erb} +0 -0
  22. data/config/routes.rb +19 -21
  23. data/{lib/generators/interpret/templates/migration.rb → db/migrate/20111108094329_create_translations.rb} +3 -4
  24. data/interpret.gemspec +3 -3
  25. data/lib/interpret/engine.rb +6 -4
  26. data/lib/interpret/helpers.rb +4 -53
  27. data/lib/interpret/version.rb +1 -1
  28. data/lib/interpret.rb +0 -4
  29. data/script/rails +5 -0
  30. data/spec/integration/missing_translations_spec.rb +8 -8
  31. data/spec/integration/search_spec.rb +8 -8
  32. data/spec/integration/stale_translations_spec.rb +5 -5
  33. data/spec/integration/tools_spec.rb +9 -9
  34. data/spec/integration/translations_spec.rb +2 -2
  35. data/spec/spec_helper.rb +2 -9
  36. data/spec/support/load_routes.rb +6 -0
  37. data/test_app/Gemfile +11 -6
  38. data/test_app/{public → app/assets}/images/a1.gif +0 -0
  39. data/test_app/{public → app/assets}/images/a10.jpg +0 -0
  40. data/test_app/{public → app/assets}/images/a16.gif +0 -0
  41. data/test_app/{public → app/assets}/images/a18.gif +0 -0
  42. data/test_app/{public → app/assets}/images/a22.gif +0 -0
  43. data/test_app/{public → app/assets}/images/a26.gif +0 -0
  44. data/test_app/{public → app/assets}/images/a33.gif +0 -0
  45. data/test_app/{public → app/assets}/images/a36.gif +0 -0
  46. data/test_app/{public → app/assets}/images/a38.gif +0 -0
  47. data/test_app/{public → app/assets}/images/a41.gif +0 -0
  48. data/test_app/{public → app/assets}/images/a47.gif +0 -0
  49. data/test_app/{public → app/assets}/images/a50.gif +0 -0
  50. data/test_app/{public → app/assets}/images/a8.gif +0 -0
  51. data/test_app/{public → app/assets}/images/abg.gif +0 -0
  52. data/test_app/{public → app/assets}/images/pic1.jpg +0 -0
  53. data/test_app/{public → app/assets}/images/pic2.jpg +0 -0
  54. data/test_app/{public → app/assets}/images/spacer.gif +0 -0
  55. data/test_app/{public → app/assets}/images/upbg.gif +0 -0
  56. data/test_app/app/assets/javascripts/application.js +4 -0
  57. data/test_app/{public → app/assets}/stylesheets/.gitkeep +0 -0
  58. data/test_app/{public/stylesheets/default.css → app/assets/stylesheets/default.css.erb} +16 -16
  59. data/test_app/{public → app/assets}/stylesheets/private.css +0 -0
  60. data/test_app/app/controllers/admin/dashboard_controller.rb +6 -0
  61. data/test_app/app/views/admin/dashboard/index.html.erb +1 -0
  62. data/test_app/app/views/layouts/application.html.erb +3 -13
  63. data/test_app/app/views/layouts/backoffice.html.erb +3 -4
  64. data/test_app/app/views/pages/index.html.erb +2 -2
  65. data/test_app/config/application.rb +12 -3
  66. data/test_app/config/environments/development.rb +0 -1
  67. data/test_app/config/initializers/interpret.rb +0 -1
  68. data/test_app/config/routes.rb +10 -1
  69. data/test_app/db/migrate/{20111021100344_interpret_create_translations.rb → 20111108094455_create_translations.rb} +3 -4
  70. data/test_app/db/schema.rb +3 -0
  71. metadata +60 -78
  72. data/app/views/interpret/translations/live_edit.html.erb +0 -11
  73. data/app/views/layouts/interpret.html.erb +0 -56
  74. data/lib/generators/interpret/migration_generator.rb +0 -25
  75. data/lib/generators/interpret/setup_generator.rb +0 -21
  76. data/lib/interpret/capistrano.rb +0 -18
  77. data/lib/interpret/controller_filter.rb +0 -12
  78. data/public/javascripts/facebox-1.3/closelabel.png +0 -0
  79. data/public/javascripts/facebox-1.3/facebox.css +0 -80
  80. data/public/javascripts/facebox-1.3/facebox.js +0 -309
  81. data/public/javascripts/facebox-1.3/loading.gif +0 -0
  82. data/public/stylesheets/interpret_live_edit_style.css +0 -38
  83. data/test_app/config/deploy.rb +0 -24
  84. data/test_app/config/initializers/rack_patch.rb +0 -13
  85. data/test_app/public/javascripts/application.js +0 -2
  86. data/test_app/public/javascripts/best_in_place.js +0 -456
  87. data/test_app/public/javascripts/facebox-1.3/closelabel.png +0 -0
  88. data/test_app/public/javascripts/facebox-1.3/facebox.css +0 -80
  89. data/test_app/public/javascripts/facebox-1.3/facebox.js +0 -309
  90. data/test_app/public/javascripts/facebox-1.3/loading.gif +0 -0
  91. data/test_app/public/javascripts/interpret.js +0 -4
  92. data/test_app/public/javascripts/rails.js +0 -134
  93. data/test_app/public/stylesheets/folder.png +0 -0
  94. data/test_app/public/stylesheets/interpret_live_edit_style.css +0 -38
  95. data/test_app/public/stylesheets/interpret_style.css +0 -535
data/.gitignore CHANGED
@@ -1,11 +1,9 @@
1
1
  pkg/*
2
2
  *.gem
3
- .bundle
3
+ .bundle/
4
4
 
5
5
  Gemfile.lock
6
6
  .DS_Store
7
- test_app/.bundle
8
7
  test_app/db/*.sqlite3
9
8
  test_app/log/*.log
10
- test_app/tmp/**/*
11
-
9
+ test_app/tmp/
data/Gemfile CHANGED
@@ -3,6 +3,5 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in interpret.gemspec
4
4
  gemspec
5
5
 
6
- group :development, :test do
7
- gem 'sqlite3-ruby', :require => 'sqlite3'
8
- end
6
+ gem 'sqlite3'
7
+ gem 'jquery-rails'
data/README.md CHANGED
@@ -422,18 +422,9 @@ backoffice.
422
422
  rake interpret:update
423
423
  rake interpret:dump
424
424
 
425
- The `update` task is what you may want to run after a deployment, for what
426
- Interpret already has a capistrano recipe...
425
+ The `update` task is what you may want to run after a deployment.
427
426
 
428
427
 
429
- Capistrano recipe
430
- -----------------
431
-
432
- Interpret also have a capistrano recipe to run the `update` rake task after
433
- updating code. You only need to require this file in your `deploy.rb`:
434
-
435
- require 'interpret/capistrano'
436
-
437
428
 
438
429
  Soft behavior
439
430
  --------------
File without changes
@@ -502,7 +502,7 @@ html body * dd.clear
502
502
  padding: .4em;
503
503
  }
504
504
  #interpret_container #tree_sidebar li {
505
- list-style-image: url("/stylesheets/folder.png");
505
+ list-style-image: url(<%= asset_path "folder.png" %>);
506
506
  font-weight: normal;
507
507
  padding-bottom: 5px;
508
508
  letter-spacing: 1px;
@@ -2,7 +2,7 @@ class Interpret::BaseController < eval(Interpret.parent_controller.classify)
2
2
  before_filter :set_locale
3
3
  before_filter { authorize! :use, :interpret }
4
4
  before_filter :check_authorized_language
5
- layout 'interpret'
5
+ layout 'interpret/interpret'
6
6
 
7
7
  protected
8
8
  def current_interpret_user
@@ -6,7 +6,7 @@ class Interpret::SearchController < Interpret::BaseController
6
6
  opts = {}
7
7
  opts[:key] = params[:key] if params[:key].present?
8
8
  opts[:value] = params[:value] if params[:value].present?
9
- redirect_to interpret_search_url(opts)
9
+ redirect_to search_url(opts)
10
10
  else
11
11
  if params[:key].present? || params[:value].present?
12
12
  sanitizer = case ActiveRecord::Base.connection.adapter_name
@@ -22,7 +22,13 @@ class Interpret::SearchController < Interpret::BaseController
22
22
  t = Interpret::Translation.arel_table
23
23
  search_key = params[:key].present? ? params[:key].split(" ").map{|x| sanitizer.call(x)} : []
24
24
  search_value = params[:value].present? ? params[:value].split(" ").map{|x| sanitizer.call(x)} : []
25
- @translations = Interpret::Translation.allowed.locale(I18n.locale).where(t[:key].matches_all(search_key).or(t[:value].matches_all(search_value))).order("translations.key ASC")
25
+ if search_value.any? && search_key.any?
26
+ @translations = Interpret::Translation.allowed.locale(I18n.locale).where(t[:key].matches_all(search_key).or(t[:value].matches_all(search_value))).order("translations.key ASC")
27
+ elsif search_key.any?
28
+ @translations = Interpret::Translation.allowed.locale(I18n.locale).where(t[:key].matches_all(search_key)).order("translations.key ASC")
29
+ else
30
+ @translations = Interpret::Translation.allowed.locale(I18n.locale).where(t[:value].matches_all(search_value)).order("translations.key ASC")
31
+ end
26
32
  end
27
33
  end
28
34
  end
@@ -6,7 +6,7 @@ class Interpret::ToolsController < Interpret::BaseController
6
6
 
7
7
  session.delete(:tree)
8
8
  Interpret.backend.reload! if Interpret.backend
9
- redirect_to interpret_tools_url, :notice => "Dump done."
9
+ redirect_to tools_url, :notice => "Dump done."
10
10
  end
11
11
 
12
12
  def export
@@ -22,26 +22,26 @@ class Interpret::ToolsController < Interpret::BaseController
22
22
  def run_update
23
23
  Interpret::Translation.update
24
24
  Interpret.backend.reload! if Interpret.backend
25
- redirect_to interpret_tools_url, :notice => "Update done"
25
+ redirect_to tools_url, :notice => "Update done"
26
26
  end
27
27
 
28
28
  def import
29
29
  unless params.has_key? :file
30
- redirect_to interpret_tools_url, :alert => "You have to select a file to import."
30
+ redirect_to tools_url, :alert => "You have to select a file to import."
31
31
  return
32
32
  end
33
33
 
34
34
  begin
35
35
  Interpret::Translation.import(params[:file])
36
36
  rescue Exception => e
37
- redirect_to interpret_tools_url, :alert => "Error when importing: #{e.message}"
37
+ redirect_to tools_url, :alert => "Error when importing: #{e.message}"
38
38
  return
39
39
  end
40
40
 
41
41
  session.delete(:tree)
42
42
  Interpret.backend.reload! if Interpret.backend
43
43
 
44
- redirect_to interpret_tools_url, :notice => "Import successfully done."
44
+ redirect_to tools_url, :notice => "Import successfully done."
45
45
  end
46
46
  end
47
47
 
@@ -1,89 +1,79 @@
1
- class Interpret::TranslationsController < Interpret::BaseController
2
- before_filter :get_tree, :only => :index
3
- authorize_resource :class => "Interpret::Translation"
1
+ module Interpret
2
+ class TranslationsController < Interpret::BaseController
3
+ before_filter :get_tree, :only => :index
4
+ authorize_resource :class => "Interpret::Translation"
4
5
 
5
- def index
6
- key = params[:key]
7
- t = Interpret::Translation.arel_table
8
- if key
9
- @translations = Interpret::Translation.allowed.locale(I18n.locale).where(t[:key].matches("#{CGI.escape(key)}.%")).order("translations.key ASC")
10
- if I18n.locale != I18n.default_locale
11
- @references = Interpret::Translation.allowed.locale(I18n.default_locale).where(t[:key].matches("#{CGI.escape(key)}.%")).order("translations.key ASC")
12
- end
13
- else
14
- @translations = Interpret::Translation.allowed.locale(I18n.locale).where(t[:key].does_not_match("%.%")).order("translations.key ASC")
15
- if I18n.locale != I18n.default_locale
16
- @references = Interpret::Translation.allowed.locale(I18n.default_locale).where(t[:key].does_not_match("%.%")).order("translations.key ASC")
6
+ def index
7
+ key = params[:key]
8
+ t = Interpret::Translation.arel_table
9
+ if key
10
+ @translations = Interpret::Translation.allowed.locale(I18n.locale).where(t[:key].matches("#{CGI.escape(key)}.%")).order("translations.key ASC")
11
+ if I18n.locale != I18n.default_locale
12
+ @references = Interpret::Translation.allowed.locale(I18n.default_locale).where(t[:key].matches("#{CGI.escape(key)}.%")).order("translations.key ASC")
13
+ end
14
+ else
15
+ @translations = Interpret::Translation.allowed.locale(I18n.locale).where(t[:key].does_not_match("%.%")).order("translations.key ASC")
16
+ if I18n.locale != I18n.default_locale
17
+ @references = Interpret::Translation.allowed.locale(I18n.default_locale).where(t[:key].does_not_match("%.%")).order("translations.key ASC")
18
+ end
17
19
  end
20
+
21
+ # not show translations inside nested folders, \w avoids dots
22
+ @translations = @translations.select{|x| x.key =~ /#{key}\.\w+$/} if key
23
+ @references = @references.select{|x| x.key =~ /#{key}\.\w+$/} if key && @references
24
+
25
+ @total_keys_number = Interpret::Translation.locale(I18n.locale).count
18
26
  end
19
27
 
20
- # not show translations inside nested folders, \w avoids dots
21
- @translations = @translations.select{|x| x.key =~ /#{key}\.\w+$/} if key
22
- @references = @references.select{|x| x.key =~ /#{key}\.\w+$/} if key && @references
28
+ def edit
29
+ @translation = Interpret::Translation.find(params[:id])
30
+ end
23
31
 
24
- @total_keys_number = Interpret::Translation.locale(I18n.locale).count
25
- end
32
+ def update
33
+ @translation = Interpret::Translation.find(params[:id])
34
+ old_value = @translation.value
26
35
 
27
- def edit
28
- @translation = Interpret::Translation.find(params[:id])
29
- end
36
+ respond_to do |format|
37
+ if @translation.update_attributes(params[:translation].presence || params[:interpret_translation])
38
+ msg = ""
39
+ msg << "By [#{@interpret_user}]. " if @interpret_user
40
+ msg << "Locale: [#{@translation.locale}], key: [#{@translation.key}]. The translation has been changed from [#{old_value}] to [#{@translation.value}]"
41
+ Interpret.logger.info msg
30
42
 
31
- def update
32
- @translation = Interpret::Translation.find(params[:id])
33
- old_value = @translation.value
43
+ format.html { redirect_to(request.env["HTTP_REFERER"]) }
44
+ format.xml { head :ok }
45
+ format.json { head :ok }
46
+ else
47
+ format.html { redirect_to(request.env["HTTP_REFERER"]) }
48
+ format.xml { render :xml => @translation.errors, :status => :unprocessable_entity }
49
+ format.json { render :status => :unprocessable_entity }
50
+ end
51
+ end
52
+ end
34
53
 
35
- respond_to do |format|
36
- if @translation.update_attributes(params[:interpret_translation])
37
- msg = ""
38
- msg << "By [#{@interpret_user}]. " if @interpret_user
39
- msg << "Locale: [#{@translation.locale}], key: [#{@translation.key}]. The translation has been changed from [#{old_value}] to [#{@translation.value}]"
40
- Interpret.logger.info msg
54
+ def create
55
+ @translation = Interpret::Translation.new params[:translation]
41
56
 
42
- format.html { redirect_to(request.env["HTTP_REFERER"]) }
43
- format.xml { head :ok }
44
- format.json { head :ok }
57
+ if @translation.save
58
+ flash[:notice] = "New translation created for #{@translation.key}"
59
+ redirect_to request.env["HTTP_REFERER"]
45
60
  else
46
- format.html { redirect_to(request.env["HTTP_REFERER"]) }
47
- format.xml { render :xml => @translation.errors, :status => :unprocessable_entity }
48
- format.json { render :status => :unprocessable_entity }
61
+ flash[:alert] = "Error when creating a new translation"
62
+ redirect_to request.env["HTTP_REFERER"]
49
63
  end
50
64
  end
51
- end
52
65
 
53
- def create
54
- @translation = Interpret::Translation.new params[:interpret_translation]
66
+ def destroy
67
+ @translation = Interpret::Translation.find(params[:id])
55
68
 
56
- if @translation.save
57
- flash[:notice] = "New translation created for #{@translation.key}"
58
- redirect_to request.env["HTTP_REFERER"]
59
- else
60
- flash[:alert] = "Error when creating a new translation"
69
+ @translation.destroy
70
+ flash[:notice] = "Translation #{@translation.key} destroyed."
61
71
  redirect_to request.env["HTTP_REFERER"]
62
72
  end
63
- end
64
-
65
- def destroy
66
- @translation = Interpret::Translation.find(params[:id])
67
-
68
- @translation.destroy
69
- flash[:notice] = "Translation #{@translation.key} destroyed."
70
- redirect_to request.env["HTTP_REFERER"]
71
- end
72
73
 
73
- def live_edit
74
- blobs = params[:key].split(".")
75
- locale = blobs.first
76
- key = blobs[1..-1].join(".")
77
- @translation = Interpret::Translation.locale(locale).find_by_key(key)
78
-
79
- respond_to do |format|
80
- format.html { render :layout => false }
74
+ private
75
+ def get_tree
76
+ @tree ||= Interpret::Translation.get_tree
81
77
  end
82
78
  end
83
-
84
- private
85
- def get_tree
86
- @tree ||= Interpret::Translation.get_tree
87
- end
88
-
89
79
  end
@@ -3,6 +3,7 @@ module Interpret
3
3
  class Translation < I18n::Backend::ActiveRecord::Translation
4
4
  default_scope order('locale ASC')
5
5
  validates_uniqueness_of :key, :scope => :locale
6
+ validates_presence_of :locale
6
7
 
7
8
  after_update :set_stale
8
9
 
@@ -18,7 +18,7 @@
18
18
  <td><%= trans.key %></td>
19
19
  <td><%= ref || "It's empty" %></td>
20
20
  <td>
21
- <%= form_for Interpret::Translation.new, :url => interpret_translations_path do |f| %>
21
+ <%= form_for Interpret::Translation.new, :url => translations_path do |f| %>
22
22
  <%= f.hidden_field "locale", :value => I18n.locale %>
23
23
  <%= f.hidden_field "key", :value => trans.key %>
24
24
  <%= f.text_area :value, :rows => 4, :cols => 60 %>
@@ -24,7 +24,7 @@
24
24
  <td><%= trans[:key] %></td>
25
25
  <td><%= trans[:ref_value] %></td>
26
26
  <td>
27
- <%= form_for Interpret::Translation.new, :url => interpret_translations_path do |f| %>
27
+ <%= form_for Interpret::Translation.new, :url => translations_path do |f| %>
28
28
  <%= f.hidden_field "locale", :value => I18n.locale %>
29
29
  <%= f.hidden_field "key", :value => trans[:key] %>
30
30
  <%= f.text_area :value, :rows => 4, :cols => 60 %>
@@ -27,12 +27,12 @@
27
27
  <td class='content' id='translation_<%= trans.id %>'>
28
28
  <%= best_in_place trans, :value,
29
29
  :type => :textarea,
30
- :path => interpret_translation_path(trans),
30
+ :path => translation_path(trans),
31
31
  :activator => "#translation_#{trans.id}",
32
32
  :sanitize => false %>
33
33
  </td>
34
34
  <td>
35
- <%= form_for trans, :url => interpret_translation_path(trans) do |f| %>
35
+ <%= form_for trans, :url => translation_path(trans) do |f| %>
36
36
  <%= f.hidden_field :stale, :value => false %>
37
37
  <%= submit_tag "Mark as OK" %>
38
38
  <% end %>
@@ -7,7 +7,7 @@
7
7
  <div id="search">
8
8
  <p>Enter a search term for the key and/or the value of the translation</p>
9
9
 
10
- <%= form_tag interpret_search_path do %>
10
+ <%= form_tag search_path do %>
11
11
  <%= label_tag "key", "Key value" %>
12
12
  <br />
13
13
  <%= text_field_tag "key" %>
@@ -18,7 +18,7 @@
18
18
  <%= @translations.size %> results found.
19
19
  </p>
20
20
  <div id="side_search">
21
- <%= form_tag interpret_search_path do %>
21
+ <%= form_tag search_path do %>
22
22
  <%= label_tag "key", "Key value" %>
23
23
  <br />
24
24
  <%= text_field_tag "key", params[:key] %>
@@ -7,7 +7,7 @@
7
7
  <p>With the following button you can download a "<%= I18n.locale %>.yml" file with the current translations for this language.</p>
8
8
 
9
9
  <p>
10
- <%= button_to "Download", export_interpret_tools_path, :method => :get %>
10
+ <%= button_to "Download", export_tools_path, :method => :get %>
11
11
  </p>
12
12
 
13
13
  <div class="header">
@@ -23,7 +23,7 @@ and if they already exists they will be overwritten.
23
23
  Remember that the first key of the YAML file you're uploading must match the current locale.
24
24
  </p>
25
25
 
26
- <%= form_tag import_interpret_tools_path, :multipart => true do %>
26
+ <%= form_tag import_tools_path, :multipart => true do %>
27
27
  <%= label_tag "File:" %>
28
28
  <%= file_field_tag :file %>
29
29
  <%= submit_tag "Upload" %>
@@ -18,7 +18,7 @@
18
18
  <td class="content" id="translation_<%= x.id %>">
19
19
  <%= best_in_place x, :value,
20
20
  :type => :textarea,
21
- :path => interpret_translation_path(x),
21
+ :path => translation_path(x),
22
22
  :activator => "#translation_#{x.id}",
23
23
  :sanitize => false %>
24
24
  </td>
@@ -34,11 +34,11 @@
34
34
  <% if trans %>
35
35
  <%= best_in_place trans, :value,
36
36
  :type => :textarea,
37
- :path => interpret_translation_path(trans),
37
+ :path => translation_path(trans),
38
38
  :activator => "#translation_#{trans.id}",
39
39
  :sanitize => false %>
40
40
  <% else %>
41
- <%= link_to "Create this missing translation", interpret_missing_translations_path %>
41
+ <%= link_to "Create this missing translation", missing_translations_path %>
42
42
  <% end %>
43
43
  </td>
44
44
  </tr>
@@ -6,10 +6,10 @@
6
6
  Previous value:
7
7
  <b>[<%= @reference.locale %>] <%= @reference.value %></b>
8
8
  </p>
9
- <%= form_for [@reference, @translation], :url => interpret_translation_translations_path(@reference) do |f| %>
9
+ <%= form_for [@reference, @translation], :url => translation_translations_path(@reference) do |f| %>
10
10
  <%= f.label :value, "Translation to [#{I18n.locale}]" %>
11
11
  <%= f.text_area :value, :value => @translation.value %>
12
12
  <%= f.submit %>
13
13
  <% end %>
14
14
 
15
- <%= link_to "Back", interpret_root_path %>
15
+ <%= link_to "Back", root_path %>
@@ -0,0 +1,55 @@
1
+ <div id="interpret_container">
2
+ <% if flash.any? %>
3
+ <div class="interpret_flash grid_16 <%= flash.keys.first %>">
4
+ <%= flash[:notice] || flash[:alert] %>
5
+ </div>
6
+ <% end %>
7
+ <div class="menu grid_12">
8
+ <%= link_to "Overview", root_path, :class => controller_name == "translations" && action_name == "index" ? "current" : "" %>
9
+
10
+ <% if can? :use, :tools%>
11
+ | <%= link_to "Tools", tools_path, :class => controller_name == "tools" ? "current" : "" %>
12
+ <% end%>
13
+
14
+ <% if can? :use, :search%>
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 %>
43
+ <% end %>
44
+ <hr />
45
+ </div>
46
+ <div class="clearfix"></div>
47
+ <div id="sidebar" class="grid_3">
48
+ <%= yield :sidebar %>
49
+ </div>
50
+ <div id="main" class="grid_13">
51
+ <%= yield %>
52
+ </div>
53
+ </div>
54
+
55
+ <%= interpret_parent_layout Interpret.layout%>
data/config/routes.rb CHANGED
@@ -1,28 +1,26 @@
1
- Rails.application.routes.draw do
2
- scope Interpret.scope do
3
- namespace :interpret do
4
- resources :translations, :only => [:destroy, :edit, :update, :create] do
5
- collection do
6
- get :live_edit
7
- end
1
+ Interpret::Engine.routes.draw do
2
+ scope ":locale" do
3
+ resources :translations, :only => [:destroy, :edit, :update, :create] do
4
+ collection do
5
+ get :live_edit
8
6
  end
7
+ end
9
8
 
10
- resources :tools, :only => :index do
11
- collection do
12
- get :export
13
- post :import
14
- post :dump
15
- post :run_update
16
- end
9
+ resources :tools, :only => :index do
10
+ collection do
11
+ get :export
12
+ post :import
13
+ post :dump
14
+ post :run_update
17
15
  end
16
+ end
18
17
 
19
- match "search", :to => "search#index"
20
- resources :missing_translations
21
- match "blank", :to => "missing_translations#blank", :as => "blank_translations"
22
- match "unused", :to => "missing_translations#unused", :as => "unused_translations"
23
- match "stale", :to => "missing_translations#stale", :as => "stale_translations"
18
+ match "search", :to => "search#index"
19
+ resources :missing_translations
20
+ match "blank", :to => "missing_translations#blank", :as => "blank_translations"
21
+ match "unused", :to => "missing_translations#unused", :as => "unused_translations"
22
+ match "stale", :to => "missing_translations#stale", :as => "stale_translations"
24
23
 
25
- root :to => "translations#index"
26
- end
24
+ root :to => "translations#index"
27
25
  end
28
26
  end
@@ -1,5 +1,5 @@
1
- class InterpretCreateTranslations < ActiveRecord::Migration
2
- def self.up
1
+ class CreateTranslations < ActiveRecord::Migration
2
+ def up
3
3
  create_table :translations do |t|
4
4
  t.string :locale
5
5
  t.string :key
@@ -10,8 +10,7 @@ class InterpretCreateTranslations < ActiveRecord::Migration
10
10
  end
11
11
  end
12
12
 
13
- def self.down
13
+ def down
14
14
  drop_table :translations
15
15
  end
16
16
  end
17
-
data/interpret.gemspec CHANGED
@@ -19,11 +19,11 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency "rails", "~> 3.0.3"
23
- s.add_dependency "i18n", "~> 0.5.0"
22
+ s.add_dependency "rails", "~> 3.1.0"
23
+ s.add_dependency "i18n", "~> 0.6.0"
24
24
  s.add_dependency "i18n-active_record"
25
25
  s.add_dependency "ya2yaml", ">= 0.30.0"
26
- s.add_dependency "best_in_place", "~> 0.2.2"
26
+ s.add_dependency "best_in_place", "~> 1.0.0"
27
27
  s.add_dependency "lazyhash", ">= 0.1.1"
28
28
  s.add_dependency "cancan", "~> 1.6.0"
29
29
 
@@ -1,10 +1,10 @@
1
- require 'i18n/backend/active_record'
2
1
  require 'interpret/logger'
3
2
  require 'interpret/helpers'
4
- require 'interpret/controller_filter'
5
3
 
6
4
  module Interpret
7
5
  class Engine < Rails::Engine
6
+ isolate_namespace Interpret
7
+
8
8
  initializer "interpret.register_i18n_active_record_backend" do |app|
9
9
  app.config.after_initialize do
10
10
  if Interpret.registered_envs.include?(Rails.env.to_sym)
@@ -25,10 +25,12 @@ module Interpret
25
25
 
26
26
 
27
27
  initializer "interpret.register_observer" do |app|
28
- app.config.before_initialize do |app|
28
+ #app.config.before_initialize do |app|
29
+ require 'active_record'
30
+ require 'i18n/backend/active_record'
29
31
  ActiveRecord::Base.observers << Interpret.sweeper.to_sym if Interpret.sweeper && I18n::Backend::ActiveRecord::Translation.table_exists?
30
32
  ActiveRecord::Base.observers << :"interpret/expiration_observer" if !Interpret.sweeper && I18n::Backend::ActiveRecord::Translation.table_exists?
31
- end
33
+ #end
32
34
  end
33
35
  end
34
36
  end