spree_simple_product_translations 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +27 -0
- data/app/views/admin/products/_product_form_left.html.erb +38 -0
- data/lib/batch_translation.rb +17 -0
- data/lib/models/product.rb +7 -0
- data/lib/spree_simple_product_translations.rb +22 -0
- data/lib/spree_simple_product_translations_hooks.rb +3 -0
- data/lib/tasks/install.rake +25 -0
- data/lib/tasks/spree_simple_product_translations.rake +1 -0
- metadata +107 -0
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Spree Extension: Simple Product Translations
|
2
|
+
This extension allows you to translate product details on an intuitive way based on tabs.
|
3
|
+
Currently it will load tabs for all locales in `I18n.available_locales`.
|
4
|
+
|
5
|
+
# Installation
|
6
|
+
In your Gemfile you just add:
|
7
|
+
|
8
|
+
gem 'spree_simple_product_translations'
|
9
|
+
|
10
|
+
Then install the gem:
|
11
|
+
|
12
|
+
bundle install
|
13
|
+
|
14
|
+
Then copy the assets to your spree application:
|
15
|
+
|
16
|
+
rake spree_product_translations:install
|
17
|
+
rake spree_simple_product_translations:install
|
18
|
+
|
19
|
+
# To add in future releases
|
20
|
+
* Tests
|
21
|
+
* Configuration option for which locales te load
|
22
|
+
* Better design?
|
23
|
+
|
24
|
+
# Patches
|
25
|
+
Feel free to fork this project and provide with any necesary patches. Tests are welcome too.
|
26
|
+
|
27
|
+
Copyright (c) 2011 [Jeroen Jacobs](https://github.com/jeroenj), released under the New BSD License
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<% content_for :head do %>
|
2
|
+
<%= javascript_include_tag 'jquery-ui-1.7.3.custom.min', 'simple_product_translations' %>
|
3
|
+
<%= stylesheet_link_tag 'smoothness/jquery-ui-1.7.3.custom' %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<div id="tabs">
|
7
|
+
<ul>
|
8
|
+
<% I18n.available_locales.each do |l| %>
|
9
|
+
<li><%= link_to t(l), "#tabs-#{l}" %></li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
<% I18n.available_locales.each do |l| %>
|
13
|
+
<div id="tabs-<%= l %>">
|
14
|
+
<%= f.globalize_fields_for l do |g| %>
|
15
|
+
<% default_locale = l.to_sym == I18n.default_locale %>
|
16
|
+
<% g = f if default_locale %>
|
17
|
+
<%= f.field_container :name do %>
|
18
|
+
<%= g.label :name, t("name") %> <% if default_locale %><span class="required">*</span><br /><% end %>
|
19
|
+
<%= g.text_field :name, :class => 'fullwidth title' %>
|
20
|
+
<%= f.error_message_on :name %>
|
21
|
+
<% end %>
|
22
|
+
<% if default_locale %>
|
23
|
+
<%= f.field_container :permalink do %>
|
24
|
+
<%= f.label :permalink, t("permalink") %> <span class="required">*</span><br />
|
25
|
+
<%= f.text_field :permalink, :class => 'fullwidth title' %>
|
26
|
+
<%= f.error_message_on :permalink %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
<%= f.field_container :description do %>
|
30
|
+
<%= g.label :description, t("description")%><br />
|
31
|
+
<%= g.text_area :description, {:cols => 60, :rows => 4, :class => 'fullwidth'} %>
|
32
|
+
<%= f.error_message_on :description %>
|
33
|
+
<% end %>
|
34
|
+
</p>
|
35
|
+
<% end %>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
38
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Do not forget to set accepts_nested_attributes_for :translations in the translated model.
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
module Helpers
|
5
|
+
class FormBuilder
|
6
|
+
def globalize_fields_for(locale, *args, &proc)
|
7
|
+
raise ArgumentError, "Missing block" unless block_given?
|
8
|
+
@index = @index ? @index + 1 : 1
|
9
|
+
object_name = "#{@object_name}[translations_attributes][#{@index}]"
|
10
|
+
object = @object.translations.select{|t| t.locale.to_s == locale}.first || @object.translations.find_by_locale(locale.to_s)
|
11
|
+
@template.concat @template.hidden_field_tag("#{object_name}[id]", object ? object.id : "")
|
12
|
+
@template.concat @template.hidden_field_tag("#{object_name}[locale]", locale)
|
13
|
+
@template.fields_for(object_name, object, *args, &proc)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spree_core'
|
2
|
+
require 'spree_product_translations'
|
3
|
+
|
4
|
+
require 'spree_simple_product_translations_hooks'
|
5
|
+
require 'batch_translation'
|
6
|
+
|
7
|
+
module SpreeSimpleProductTranslations
|
8
|
+
class Engine < Rails::Engine
|
9
|
+
|
10
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
11
|
+
|
12
|
+
def self.activate
|
13
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
|
14
|
+
Rails.env.production? ? require(c) : load(c)
|
15
|
+
end
|
16
|
+
|
17
|
+
::Product.send :include, Models::Product
|
18
|
+
end
|
19
|
+
|
20
|
+
config.to_prepare &method(:activate).to_proc
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :spree_simple_product_translations do
|
2
|
+
desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
|
3
|
+
task :install do
|
4
|
+
Rake::Task['spree_simple_product_translations:install:migrations'].invoke
|
5
|
+
Rake::Task['spree_simple_product_translations:install:assets'].invoke
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :install do
|
9
|
+
desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
|
10
|
+
task :migrations do
|
11
|
+
source = File.join(File.dirname(__FILE__), '..', '..', 'db')
|
12
|
+
destination = File.join(Rails.root, 'db')
|
13
|
+
Spree::FileUtilz.mirror_files(source, destination)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
|
17
|
+
task :assets do
|
18
|
+
source = File.join(File.dirname(__FILE__), '..', '..', 'public')
|
19
|
+
destination = File.join(Rails.root, 'public')
|
20
|
+
puts "INFO: Mirroring assets from #{source} to #{destination}"
|
21
|
+
Spree::FileUtilz.mirror_files(source, destination)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# add custom rake tasks here
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_simple_product_translations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jeroen Jacobs
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-02 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: spree_core
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 185
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 40
|
33
|
+
- 3
|
34
|
+
version: 0.40.3
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: spree_product_translations
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 29
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 0
|
49
|
+
- 1
|
50
|
+
version: 0.0.1
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
description:
|
54
|
+
email: jacobsjeroen@gmail.com
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files: []
|
60
|
+
|
61
|
+
files:
|
62
|
+
- README.md
|
63
|
+
- lib/batch_translation.rb
|
64
|
+
- lib/models/product.rb
|
65
|
+
- lib/spree_simple_product_translations.rb
|
66
|
+
- lib/spree_simple_product_translations_hooks.rb
|
67
|
+
- lib/tasks/install.rake
|
68
|
+
- lib/tasks/spree_simple_product_translations.rake
|
69
|
+
- app/views/admin/products/_product_form_left.html.erb
|
70
|
+
has_rdoc: false
|
71
|
+
homepage: https://github.com/jeroenj/spree-simple_product_translations
|
72
|
+
licenses: []
|
73
|
+
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 57
|
85
|
+
segments:
|
86
|
+
- 1
|
87
|
+
- 8
|
88
|
+
- 7
|
89
|
+
version: 1.8.7
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
requirements:
|
100
|
+
- none
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.5.0
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: Spree Extension that adds an intuitive way to translate product details in the backend
|
106
|
+
test_files: []
|
107
|
+
|