translation_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/config/initializers/app_config.rb +22 -0
- data/config/routes.rb +3 -0
- data/config/translation_center.yml +55 -0
- data/db/migrate/20130522073522681241_create_translation_center_categories.rb +9 -0
- data/db/migrate/20130522073522682472_create_translation_center_translation_keys.rb +16 -0
- data/db/migrate/20130522073522683554_create_translation_center_translations.rb +13 -0
- data/db/migrate/20130522073522683555_install_audited.rb +28 -0
- data/db/migrate/20130522073522_acts_as_votable_migration.rb +23 -0
- data/db/migrate/20130523095615_create_managers.rb +10 -0
- data/lib/translation_rails/engine.rb +9 -0
- data/lib/translation_rails/sprockets.rb +25 -0
- data/lib/translation_rails/translation_center.rb +7 -0
- data/lib/translation_rails/version.rb +3 -0
- data/lib/translation_rails.rb +4 -0
- metadata +92 -0
@@ -0,0 +1,22 @@
|
|
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.where(email: "tech@e-accent.com").first
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
common_atts: &common_atts
|
2
|
+
# what language to support and their display names
|
3
|
+
lang:
|
4
|
+
en:
|
5
|
+
name: 'English'
|
6
|
+
direction: 'ltr'
|
7
|
+
nl:
|
8
|
+
name: 'Dutch'
|
9
|
+
direction: 'ltr'
|
10
|
+
|
11
|
+
# yaml imported translations created by translator email, usually User email
|
12
|
+
yaml_translator_identifier: 'tech@e-accent.com'
|
13
|
+
|
14
|
+
# when import translation from yaml to db set it to accepted by default
|
15
|
+
yaml2db_translations_accepted: true # default is false
|
16
|
+
|
17
|
+
# when admins add/edit translations they are considered accepted directly
|
18
|
+
accept_admin_translations: true
|
19
|
+
|
20
|
+
identifier_type: 'email' # Uncomment and change the identifier if your User model has no email attribute
|
21
|
+
translator_type: 'Manager' # Uncomment and change if you want to change the translator type
|
22
|
+
|
23
|
+
development:
|
24
|
+
enabled: true # default false
|
25
|
+
|
26
|
+
# Keys inspector allowed values:
|
27
|
+
# "missing" to inspect only untranslated keys
|
28
|
+
# "all" to enable inspector for translated and untranslated keys
|
29
|
+
# "off" to turn off keys inspector
|
30
|
+
inspector: 'all' # default missing
|
31
|
+
|
32
|
+
# I18n.translate source
|
33
|
+
i18n_source: 'yaml' # can be db or yaml; default is yaml
|
34
|
+
|
35
|
+
# when a new key is added to db, the value of the key is added as the default translation in English
|
36
|
+
save_default_translation: true
|
37
|
+
|
38
|
+
<<: *common_atts
|
39
|
+
|
40
|
+
production:
|
41
|
+
enabled: false # default false
|
42
|
+
|
43
|
+
# Keys inspector allowed values:
|
44
|
+
# "missing" to inspect only untranslated keys
|
45
|
+
# "all" to enable inspector for translated and untranslated keys
|
46
|
+
# "off" to turn off keys inspector
|
47
|
+
inspector: 'off' # default missing
|
48
|
+
|
49
|
+
# I18n.translate source
|
50
|
+
i18n_source: 'yaml' # can be db or yaml; default is yaml
|
51
|
+
|
52
|
+
# when a new key is added to db, the value of the key is added as the default translation in English
|
53
|
+
save_default_translation: false
|
54
|
+
|
55
|
+
<<: *common_atts
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateTranslationCenterTranslationKeys < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :translation_center_translation_keys do |t|
|
4
|
+
t.string :name
|
5
|
+
t.integer :category_id
|
6
|
+
t.datetime :last_accessed
|
7
|
+
|
8
|
+
t.string :en_status, default: 'untranslated'
|
9
|
+
|
10
|
+
t.string :nl_status, default: 'untranslated'
|
11
|
+
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateTranslationCenterTranslations < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :translation_center_translations do |t|
|
4
|
+
t.integer :translation_key_id
|
5
|
+
t.string :value
|
6
|
+
t.string :lang
|
7
|
+
t.references :translator, polymorphic: true
|
8
|
+
t.string :status, default: 'pending'
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class InstallAudited < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :audits, :force => true do |t|
|
4
|
+
t.column :auditable_id, :integer
|
5
|
+
t.column :auditable_type, :string
|
6
|
+
t.column :associated_id, :integer
|
7
|
+
t.column :associated_type, :string
|
8
|
+
t.column :user_id, :integer
|
9
|
+
t.column :user_type, :string
|
10
|
+
t.column :username, :string
|
11
|
+
t.column :action, :string
|
12
|
+
t.column :audited_changes, :text
|
13
|
+
t.column :version, :integer, :default => 0
|
14
|
+
t.column :comment, :string
|
15
|
+
t.column :remote_address, :string
|
16
|
+
t.column :created_at, :datetime
|
17
|
+
end
|
18
|
+
|
19
|
+
add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
|
20
|
+
add_index :audits, [:associated_id, :associated_type], :name => 'associated_index'
|
21
|
+
add_index :audits, [:user_id, :user_type], :name => 'user_index'
|
22
|
+
add_index :audits, :created_at
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.down
|
26
|
+
drop_table :audits
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class ActsAsVotableMigration < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :votes do |t|
|
4
|
+
|
5
|
+
t.references :votable, :polymorphic => true
|
6
|
+
t.references :voter, :polymorphic => true
|
7
|
+
|
8
|
+
t.boolean :vote_flag
|
9
|
+
t.string :vote_scope
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :votes, [:votable_id, :votable_type]
|
15
|
+
add_index :votes, [:voter_id, :voter_type]
|
16
|
+
add_index :votes, [:voter_id, :voter_type, :vote_scope]
|
17
|
+
add_index :votes, [:votable_id, :votable_type, :vote_scope]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.down
|
21
|
+
drop_table :votes
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "sprockets"
|
2
|
+
|
3
|
+
module Sprockets
|
4
|
+
class BundledAsset
|
5
|
+
def initialize(environment, logical_path, pathname)
|
6
|
+
super(environment, logical_path, pathname)
|
7
|
+
@processed_asset = environment.find_asset(pathname, :bundle => false)
|
8
|
+
translationcenter_inspector = environment.find_asset("translation_center/inspector.js", :bundle => false)
|
9
|
+
|
10
|
+
@required_assets = @processed_asset.required_assets + translationcenter_inspector.send(:required_assets)
|
11
|
+
@dependency_paths = @processed_asset.dependency_paths + translationcenter_inspector.dependency_paths
|
12
|
+
# Explode Asset into parts and gather the dependency bodies
|
13
|
+
@source = to_a.map { |dependency| dependency.to_s }.join
|
14
|
+
|
15
|
+
# Run bundle processors on concatenated source
|
16
|
+
context = environment.context_class.new(environment, logical_path, pathname)
|
17
|
+
@source = context.evaluate(pathname, :data => @source,
|
18
|
+
:processors => environment.bundle_processors(content_type))
|
19
|
+
|
20
|
+
@mtime = (to_a + @dependency_paths).map(&:mtime).max
|
21
|
+
@length = Rack::Utils.bytesize(source)
|
22
|
+
@digest = environment.digest.update(source).hexdigest
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: translation_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jio
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: translation_center
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Translation Rails
|
47
|
+
email:
|
48
|
+
- jypandjio@163.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- config/initializers/app_config.rb
|
54
|
+
- config/routes.rb
|
55
|
+
- config/translation_center.yml
|
56
|
+
- db/migrate/20130522073522681241_create_translation_center_categories.rb
|
57
|
+
- db/migrate/20130522073522682472_create_translation_center_translation_keys.rb
|
58
|
+
- db/migrate/20130522073522683554_create_translation_center_translations.rb
|
59
|
+
- db/migrate/20130522073522683555_install_audited.rb
|
60
|
+
- db/migrate/20130522073522_acts_as_votable_migration.rb
|
61
|
+
- db/migrate/20130523095615_create_managers.rb
|
62
|
+
- lib/translation_rails/engine.rb
|
63
|
+
- lib/translation_rails/sprockets.rb
|
64
|
+
- lib/translation_rails/translation_center.rb
|
65
|
+
- lib/translation_rails/version.rb
|
66
|
+
- lib/translation_rails.rb
|
67
|
+
homepage: ''
|
68
|
+
licenses: []
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.23
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: Translation Rails
|
91
|
+
test_files: []
|
92
|
+
has_rdoc:
|