translation_rails 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/{translation_rails/application_controller.rb → application_controller.rb} +0 -0
- data/config/initializers/app_configs.rb +48 -0
- data/lib/tasks/translation_rails.rake +5 -1
- data/lib/translation_rails/dependencies.rb +24 -0
- data/lib/translation_rails/engine.rb +1 -0
- data/lib/translation_rails/version.rb +1 -1
- metadata +4 -3
- data/config/initializers/app_config.rb +0 -22
data/app/controllers/{translation_rails/application_controller.rb → application_controller.rb}
RENAMED
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
Rails.application.paths["db/migrate"] = [File.expand_path("../../../db/migrate", __FILE__), "db/migrate"]
|
2
|
+
|
3
|
+
module TranslationCenter
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
|
6
|
+
helper_method :current_user
|
7
|
+
|
8
|
+
def authenticate_user!
|
9
|
+
if current_user.blank?
|
10
|
+
redirect_to "/", :alert => "You must login to access this page."
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def current_user
|
15
|
+
@current_user ||=
|
16
|
+
if session[:current_user_id].present?
|
17
|
+
Manager.find_by_email(TranslationCenter::CONFIG['yaml_translator_identifier'])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# class ApplicationController < ActionController::Base
|
25
|
+
# layout "translation_rails/application"
|
26
|
+
# before_filter :get_original_layout
|
27
|
+
|
28
|
+
# def self.layout(layout, conditions={})
|
29
|
+
# unless layout.to_s == "translation_rails/application"
|
30
|
+
# self.original_layout = layout.to_s
|
31
|
+
# end
|
32
|
+
# layout = "translation_rails/application"
|
33
|
+
# super
|
34
|
+
# end
|
35
|
+
|
36
|
+
# def self.original_layout=(layout)
|
37
|
+
# @original_layout = layout
|
38
|
+
# end
|
39
|
+
|
40
|
+
# def self.original_layout
|
41
|
+
# @original_layout || "translation_rails/application"
|
42
|
+
# end
|
43
|
+
|
44
|
+
|
45
|
+
# def get_original_layout
|
46
|
+
# @layout_name = self.class.original_layout
|
47
|
+
# end
|
48
|
+
# end
|
@@ -3,7 +3,7 @@ namespace :translation_rails do
|
|
3
3
|
|
4
4
|
def migrate(lang, direction)
|
5
5
|
eval "Add#{lang.camelize}Status = Class.new(ActiveRecord::Migration)"
|
6
|
-
"Add#{lang.
|
6
|
+
"Add#{lang.camelize}Status".constantize.class_eval do
|
7
7
|
define_method :change do
|
8
8
|
add_column :translation_center_translation_keys, "#{lang}_status", :string, default: 'untranslated'
|
9
9
|
end
|
@@ -20,4 +20,8 @@ namespace :translation_rails do
|
|
20
20
|
lang = args[:lang].to_s
|
21
21
|
migrate(lang, :down)
|
22
22
|
end
|
23
|
+
|
24
|
+
task :install, :environment do
|
25
|
+
|
26
|
+
end
|
23
27
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'active_support/dependencies'
|
2
|
+
module ActiveSupport
|
3
|
+
module Dependencies
|
4
|
+
module Extend
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.class_eval do
|
8
|
+
alias_method_chain :require_or_load, :translation_rails
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def require_or_load_with_translation_rails(file_name, const_path = nil)
|
13
|
+
require_or_load_without_translation_rails(file_name, const_path)
|
14
|
+
if file_name.starts_with?(Rails.root.to_s + '/app')
|
15
|
+
relative_name = file_name.gsub(Rails.root.to_s, '')
|
16
|
+
engine_file = File.join(TranslationRails::Engine.root, relative_name)
|
17
|
+
require_or_load_without_translation_rails(engine_file, const_path) if File.file?(engine_file)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
include Extend
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translation_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -51,10 +51,10 @@ extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
53
|
- app/assets/stylesheets/application.css
|
54
|
-
- app/controllers/
|
54
|
+
- app/controllers/application_controller.rb
|
55
55
|
- app/models/manager.rb
|
56
56
|
- app/views/layouts/translation_rails/application.html.erb
|
57
|
-
- config/initializers/
|
57
|
+
- config/initializers/app_configs.rb
|
58
58
|
- config/routes.rb
|
59
59
|
- config/translation_center.yml
|
60
60
|
- db/migrate/001_create_translation_center_categories.rb
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- db/migrate/006_create_managers.rb
|
66
66
|
- lib/generators/translation_rails/install/install_generator.rb
|
67
67
|
- lib/tasks/translation_rails.rake
|
68
|
+
- lib/translation_rails/dependencies.rb
|
68
69
|
- lib/translation_rails/engine.rb
|
69
70
|
- lib/translation_rails/translation_center.rb
|
70
71
|
- lib/translation_rails/version.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
Rails.application.paths["db/migrate"] = [File.expand_path("../../../db/migrate", __FILE__), "db/migrate"]
|
2
|
-
|
3
|
-
module TranslationCenter
|
4
|
-
class ApplicationController < ActionController::Base
|
5
|
-
|
6
|
-
helper_method :current_user
|
7
|
-
|
8
|
-
def authenticate_user!
|
9
|
-
if current_user.blank?
|
10
|
-
redirect_to "/", :alert => "You must login to access this page."
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def current_user
|
15
|
-
@current_user ||=
|
16
|
-
if session[:current_user_id].present?
|
17
|
-
Manager.find_by_email(TranslationCenter::CONFIG['yaml_translator_identifier'])
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|