translation_rails 0.0.1 → 0.0.2

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/README.md ADDED
@@ -0,0 +1,24 @@
1
+ translation-rails
2
+ =================
3
+
4
+ include translation_center use it
5
+
6
+ HOW USE
7
+
8
+ gem 'translation_center', :git => "https://github.com/jypandjio/translation_center"
9
+
10
+ gem 'translation_rails'
11
+
12
+ rake db:migrate
13
+
14
+ To migrate translations from TranslationCenter database to yaml files
15
+
16
+ rake translation_center:db2yaml
17
+
18
+ To migrate translations from yaml files to TranslationCenter database
19
+
20
+ rake translation_center:yaml2db
21
+
22
+
23
+
24
+
@@ -0,0 +1,4 @@
1
+ /*
2
+ *= require_self
3
+ *= require translation_center/inspector
4
+ */
@@ -0,0 +1,25 @@
1
+ class ApplicationController
2
+ layout "translation_rails/application"
3
+
4
+ def self.layout(layout, conditions={})
5
+ unless layout.to_s == "translation_rails/application"
6
+ self.original_layout = layout.to_s
7
+ end
8
+ layout = "translation_rails/application"
9
+ super
10
+ end
11
+
12
+ def self.original_layout=(layout)
13
+ @original_layout = layout
14
+ end
15
+
16
+ def self.original_layout
17
+ @original_layout || "translation_rails/application"
18
+ end
19
+
20
+ before_filter :get_original_layout
21
+
22
+ def get_original_layout
23
+ @layout_name = self.class.original_layout
24
+ end
25
+ end
@@ -0,0 +1,4 @@
1
+ class Manager < ActiveRecord::Base
2
+ acts_as_translator
3
+ attr_accessible :email, :password
4
+ end
@@ -0,0 +1,12 @@
1
+ <% if TranslationCenter::CONFIG["enabled"] %>
2
+ <%= content_for :head do %>
3
+ <%= stylesheet_link_tag "translation_center/inspector" %>
4
+ <%= javascript_include_tag "translation_center/inspector" %>
5
+ <% end %>
6
+ <% end %>
7
+
8
+ <% if ["translation_rails/application", "application"].include?(@layout_name) %>
9
+ <%= render template: 'layouts/application' %>
10
+ <% else %>
11
+ <%= render template: "layouts/#{@layout_name}"%>
12
+ <% end %>
@@ -14,7 +14,7 @@ module TranslationCenter
14
14
  def current_user
15
15
  @current_user ||=
16
16
  if session[:current_user_id].present?
17
- Manager.where(email: "tech@e-accent.com").first
17
+ Manager.find_by_email(TranslationCenter::CONFIG['yaml_translator_identifier'])
18
18
  end
19
19
  end
20
20
 
@@ -4,12 +4,9 @@ common_atts: &common_atts
4
4
  en:
5
5
  name: 'English'
6
6
  direction: 'ltr'
7
- nl:
8
- name: 'Dutch'
9
- direction: 'ltr'
10
7
 
11
8
  # yaml imported translations created by translator email, usually User email
12
- yaml_translator_identifier: 'tech@e-accent.com'
9
+ yaml_translator_identifier: 'tech@example.com'
13
10
 
14
11
  # when import translation from yaml to db set it to accepted by default
15
12
  yaml2db_translations_accepted: true # default is false
@@ -7,3 +7,5 @@ class CreateTranslationCenterCategories < ActiveRecord::Migration
7
7
  end
8
8
  end
9
9
  end
10
+
11
+ #20130522073522681241
@@ -4,13 +4,12 @@ class CreateTranslationCenterTranslationKeys < ActiveRecord::Migration
4
4
  t.string :name
5
5
  t.integer :category_id
6
6
  t.datetime :last_accessed
7
-
8
- t.string :en_status, default: 'untranslated'
9
-
10
- t.string :nl_status, default: 'untranslated'
11
-
12
-
13
7
  t.timestamps
14
8
  end
15
9
  end
16
10
  end
11
+
12
+ # 20130522073522682472
13
+
14
+
15
+
@@ -11,3 +11,5 @@ class CreateTranslationCenterTranslations < ActiveRecord::Migration
11
11
  end
12
12
  end
13
13
  end
14
+
15
+ # 20130522073522683554
@@ -26,3 +26,6 @@ class InstallAudited < ActiveRecord::Migration
26
26
  drop_table :audits
27
27
  end
28
28
  end
29
+
30
+
31
+ # 20130522073522683555
@@ -21,3 +21,6 @@ class ActsAsVotableMigration < ActiveRecord::Migration
21
21
  drop_table :votes
22
22
  end
23
23
  end
24
+
25
+
26
+ # 20130522073522
@@ -8,3 +8,5 @@ class CreateManagers < ActiveRecord::Migration
8
8
  end
9
9
  end
10
10
  end
11
+
12
+ # 20130523095615
@@ -0,0 +1,21 @@
1
+ module TranslationRails
2
+ class InstallGenerator < Rails::Generators::Base
3
+ source_root TranslationRails::Engine.root
4
+
5
+ def install_config
6
+ copy_file 'config/translation_center.yml', 'config/translation_center.yml'
7
+ ignore_file("config/translation_center.yml")
8
+ end
9
+
10
+ def create_locales
11
+ FileUtils.mkdir_p("config/locales")
12
+ ignore_file("config/locales")
13
+ end
14
+
15
+ private
16
+
17
+ def ignore_file(file_name)
18
+ append_file ".gitignore", "\n#{file_name}", force: true
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+
2
+ namespace :translation_rails do
3
+
4
+ def migrate(lang, direction)
5
+ eval "Add#{lang.camelize}Status = Class.new(ActiveRecord::Migration)"
6
+ "Add#{lang.to_s.camelize}Status".constantize.class_eval do
7
+ define_method :change do
8
+ add_column :translation_center_translation_keys, "#{lang}_status", :string, default: 'untranslated'
9
+ end
10
+ end
11
+ "Add#{lang.camelize}Status".constantize.migrate(direction)
12
+ end
13
+
14
+ task :add_lang, [:lang] => :environment do |t, args|
15
+ lang = args[:lang].to_s
16
+ migrate(lang, :up)
17
+ end
18
+
19
+ task :delete_lang, [:lang] => :environment do |t, args|
20
+ lang = args[:lang].to_s
21
+ migrate(lang, :down)
22
+ end
23
+ end
@@ -1,5 +1,4 @@
1
1
  require "active_record/railtie"
2
- require "translation_rails/sprockets"
3
2
  require 'translation_rails/translation_center'
4
3
 
5
4
  module TranslationRails
@@ -1,3 +1,3 @@
1
1
  module TranslationRails
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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.1
4
+ version: 0.0.2
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: 2013-05-31 00:00:00.000000000 Z
12
+ date: 2013-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -50,20 +50,26 @@ executables: []
50
50
  extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
+ - app/assets/stylesheets/application.css
54
+ - app/controllers/application_controller.rb
55
+ - app/models/manager.rb
56
+ - app/views/layouts/translation_rails/application.html.erb
53
57
  - config/initializers/app_config.rb
54
58
  - config/routes.rb
55
59
  - 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
60
+ - db/migrate/001_create_translation_center_categories.rb
61
+ - db/migrate/002_create_translation_center_translation_keys.rb
62
+ - db/migrate/003_create_translation_center_translations.rb
63
+ - db/migrate/004_install_audited.rb
64
+ - db/migrate/005_acts_as_votable_migration.rb
65
+ - db/migrate/006_create_managers.rb
66
+ - lib/generators/translation_rails/install/install_generator.rb
67
+ - lib/tasks/translation_rails.rake
62
68
  - lib/translation_rails/engine.rb
63
- - lib/translation_rails/sprockets.rb
64
69
  - lib/translation_rails/translation_center.rb
65
70
  - lib/translation_rails/version.rb
66
71
  - lib/translation_rails.rb
72
+ - README.md
67
73
  homepage: ''
68
74
  licenses: []
69
75
  post_install_message:
@@ -1,25 +0,0 @@
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