tenon 1.0.65 → 1.0.66

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e33a7bcbe83620049590477001174c6502470f68
4
- data.tar.gz: 4ee85644ad478a15431d230e94ff69368ef03b1c
3
+ metadata.gz: 6c47ddfef8b5f95e621152747059627227194e6f
4
+ data.tar.gz: 630d65af384604dc27d82c2f3278a95c32718e98
5
5
  SHA512:
6
- metadata.gz: 7717739a612188038fc4753b0d6781401680f34a0ddba34722b56c495d57ada33dc9c6a5cb6198b345578ba37438ece1474fdafdb1478d594542c6a392992d42
7
- data.tar.gz: 7f57354946919dd4ba149ddf316026903cb029d3a3b807fff67994d75073c6d6d951abdba581e1db8bbdbcaeb4c5b4980f0b6fc4f12c7b7bd2e24cbf2da47427
6
+ metadata.gz: 3b948e2e9457a41add44da0dc23e41f8c177d176af11697de77de8718a4984eea17195a01f163b43718b721df5bf75c6218aa3effa0842d12aff2de41520e36a
7
+ data.tar.gz: 49ee9f9d28640cf25557e7f2abcde8e303fc983be161808f7d816aef67300640d58a58c9768a4d95a79a507e880590521cdda09dbc72901001b8f7080affd92a
data/README.rdoc CHANGED
@@ -79,7 +79,11 @@ languages and provides an interface for managing content in multiple languages.
79
79
 
80
80
  To add internationalized fields, follow these steps:
81
81
 
82
- 1. Tell Tenon which languages you want to support in config/initializers/tenon.rb (You don't need to add English, Tenon always assumes its in use.)
82
+ 1. Add our 'translates' gem to your Gemfile and then bundle install
83
+
84
+ gem 'translates', git: 'https://github.com/factore/translates.git'
85
+
86
+ 2. Tell Tenon which languages you want to support in config/initializers/tenon.rb (You don't need to add English, Tenon always assumes its in use.)
83
87
 
84
88
  config.languages = {
85
89
  "French" => :fr,
@@ -87,7 +91,9 @@ To add internationalized fields, follow these steps:
87
91
  # etc.
88
92
  }
89
93
 
90
- 2. Create or update config/i18n_fields.yml to tell Tenon which fields you would like to have internationalized.
94
+ 3. Add a language yml file in config/locales/ for each language defined above, or rails will have a fit, eg 'config/locales/fr.yml'
95
+
96
+ 4. Create or update config/i18n_fields.yml to tell Tenon which fields you would like to have internationalized.
91
97
 
92
98
  tables:
93
99
  cars:
@@ -98,21 +104,8 @@ To add internationalized fields, follow these steps:
98
104
  - title
99
105
  - location
100
106
  - description
101
-
102
- 3. Generate and run the internationalization migration. The generator will only try to create columns that don't already exist, so you can use this generator multiple times throughout the development of your application.
103
-
104
- rails generate tenon:i18n_migrations
105
- rake db:migrate
106
-
107
- 4. Ensure that you have passed the i18n: true flag anywhere you are using tenon_content on a model.
108
-
109
- class MyModel < ActiveRecord::Base
110
- tenon_content :description, i18n: true
111
- end
112
-
113
- Once you've done this and restarted your app you will see a language selection nav in the sidebar of each form that has internationalized fields.
114
-
115
- If you want to add internationalization to the default Tenon models you should make your i18n_fields.yml look like this:
107
+
108
+ If you want to add internationalization to the default Tenon models you should make your i18n_fields.yml look like this:
116
109
 
117
110
  tables:
118
111
  tenon/events:
@@ -130,4 +123,34 @@ If you want to add internationalization to the default Tenon models you should m
130
123
  - excerpt
131
124
  - seo_title
132
125
  - seo_keywords
133
- - seo_description
126
+ - seo_description
127
+
128
+ 5. Generate and run the internationalization migration. The generator will only try to create columns that don't already exist, so you can use this generator multiple times throughout the development of your application.
129
+
130
+ rails generate tenon:i18n_migrations
131
+ rake db:migrate
132
+
133
+ 6. Update your models to make sure your attributes are translated
134
+
135
+ class MyModel < ActiveRecord::Base
136
+ include Translates
137
+ # plain old rails attributes
138
+ translates :title
139
+ # tenon_content
140
+ tenon_content :description, i18n: true
141
+ end
142
+
143
+ 7. Update your tenon views to add the language navigation helper, where needed:
144
+ # app/views/tenon/cars/_form.html.haml
145
+ - content_for :sidebar do
146
+ .sidebar
147
+ .content
148
+ ...
149
+ = i18n_language_nav(:cars)
150
+ ...
151
+
152
+ 8. While there, make sure you are using 'autosaving_form_for' instead of 'form_for' to create your forms. By doing this, Tenon will automatically update the labels when the different languages are selected.
153
+
154
+ 9. Make sure your routes are configured according to your needs and the I18n.locale is being set somehow (see Rails documentation for more info: http://guides.rubyonrails.org/i18n.html)
155
+
156
+ Once you've done this and restarted your app you will see a language selection nav in the sidebar of each Tenon form that has internationalized fields. On the front end, attributes on your Tenon models will be translated correctly, based on I18n.locale.
@@ -12,7 +12,7 @@ module Tenon
12
12
  end
13
13
 
14
14
  def save_draft_button(obj)
15
- path = new_item_version_path(item_type: obj.class.to_s, item_id: obj.id)
15
+ path = new_item_version_path(item_type: class_for(obj), item_id: obj.id)
16
16
  css_class = 'btn btn-primary btn-block draft'
17
17
  data = {
18
18
  'modal-remote' => true,
@@ -39,9 +39,17 @@ module Tenon
39
39
 
40
40
  private
41
41
 
42
+ def class_for(obj)
43
+ if obj.class < Draper::Decorator
44
+ obj.object.class.to_s
45
+ else
46
+ obj.class.to_s
47
+ end
48
+ end
49
+
42
50
  def build_data(obj, opts)
43
51
  data = {
44
- 'item-type' => obj.class.to_s,
52
+ 'item-type' => class_for(obj),
45
53
  'item-id' => obj.id,
46
54
  'autosave' => !params[:version],
47
55
  'version-create-path' => item_versions_path
data/lib/tenon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tenon
2
- VERSION = '1.0.65'
2
+ VERSION = '1.0.66'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tenon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.65
4
+ version: 1.0.66
5
5
  platform: ruby
6
6
  authors:
7
7
  - factor[e] design initiative
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-28 00:00:00.000000000 Z
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: better_errors