formtastic 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +2 -2
- data/lib/formtastic.rb +7 -7
- data/lib/formtastic/i18n.rb +8 -8
- data/spec/commit_button_spec.rb +6 -6
- data/spec/i18n_spec.rb +4 -4
- data/spec/spec_helper.rb +2 -2
- metadata +3 -3
data/README.textile
CHANGED
@@ -337,7 +337,7 @@ Formtastic supports localized *labels*, *hints*, *legends*, *actions* using the
|
|
337
337
|
title: "Choose a good title for you post."
|
338
338
|
body: "Write something inspiring here."
|
339
339
|
actions:
|
340
|
-
create: "Create my
|
340
|
+
create: "Create my {{model}}"
|
341
341
|
update: "Save changes"
|
342
342
|
dummie: "Launch!"
|
343
343
|
</pre>
|
@@ -354,7 +354,7 @@ Formtastic supports localized *labels*, *hints*, *legends*, *actions* using the
|
|
354
354
|
<%= form.input :section %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
|
355
355
|
<% end %>
|
356
356
|
<% form.buttons do %>
|
357
|
-
<%= form.commit_button %> # => "Create my
|
357
|
+
<%= form.commit_button %> # => "Create my {{model}}"
|
358
358
|
<% end %>
|
359
359
|
<% end %>
|
360
360
|
</pre>
|
data/lib/formtastic.rb
CHANGED
@@ -1595,9 +1595,9 @@ module Formtastic #:nodoc:
|
|
1595
1595
|
#
|
1596
1596
|
# Lookup priority:
|
1597
1597
|
#
|
1598
|
-
# 'formtastic
|
1599
|
-
# 'formtastic
|
1600
|
-
# 'formtastic
|
1598
|
+
# 'formtastic.{{type}}.{{model}}.{{action}}.{{attribute}}'
|
1599
|
+
# 'formtastic.{{type}}.{{model}}.{{attribute}}'
|
1600
|
+
# 'formtastic.{{type}}.{{attribute}}'
|
1601
1601
|
#
|
1602
1602
|
# Example:
|
1603
1603
|
#
|
@@ -1622,10 +1622,10 @@ module Formtastic #:nodoc:
|
|
1622
1622
|
|
1623
1623
|
defaults = ::Formtastic::I18n::SCOPES.collect do |i18n_scope|
|
1624
1624
|
i18n_path = i18n_scope.dup
|
1625
|
-
i18n_path.gsub!('
|
1626
|
-
i18n_path.gsub!('
|
1627
|
-
i18n_path.gsub!('
|
1628
|
-
i18n_path.gsub!('
|
1625
|
+
i18n_path.gsub!('{{action}}', action_name)
|
1626
|
+
i18n_path.gsub!('{{model}}', model_name)
|
1627
|
+
i18n_path.gsub!('{{nested_model}}', nested_model_name) unless nested_model_name.nil?
|
1628
|
+
i18n_path.gsub!('{{attribute}}', attribute_name)
|
1629
1629
|
i18n_path.gsub!('..', '.')
|
1630
1630
|
i18n_path.to_sym
|
1631
1631
|
end
|
data/lib/formtastic/i18n.rb
CHANGED
@@ -7,16 +7,16 @@ module Formtastic
|
|
7
7
|
:required => 'required',
|
8
8
|
:yes => 'Yes',
|
9
9
|
:no => 'No',
|
10
|
-
:create => 'Create
|
11
|
-
:update => 'Update
|
10
|
+
:create => 'Create {{model}}',
|
11
|
+
:update => 'Update {{model}}'
|
12
12
|
}.freeze
|
13
13
|
SCOPES = [
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
14
|
+
'{{model}}.{{nested_model}}.{{action}}.{{attribute}}',
|
15
|
+
'{{model}}.{{action}}.{{attribute}}',
|
16
|
+
'{{model}}.{{nested_model}}.{{attribute}}',
|
17
|
+
'{{model}}.{{attribute}}',
|
18
|
+
'{{nested_model}}.{{attribute}}',
|
19
|
+
'{{attribute}}'
|
20
20
|
]
|
21
21
|
|
22
22
|
class << self
|
data/spec/commit_button_spec.rb
CHANGED
@@ -136,7 +136,7 @@ describe 'SemanticFormBuilder#commit_button' do
|
|
136
136
|
describe 'when no explicit label is provided' do
|
137
137
|
describe 'when no I18n-localized label is provided' do
|
138
138
|
before do
|
139
|
-
::I18n.backend.store_translations :en, :formtastic => {:submit => 'Submit
|
139
|
+
::I18n.backend.store_translations :en, :formtastic => {:submit => 'Submit {{model}}'}
|
140
140
|
end
|
141
141
|
|
142
142
|
after do
|
@@ -171,7 +171,7 @@ describe 'SemanticFormBuilder#commit_button' do
|
|
171
171
|
:formtastic => {
|
172
172
|
:actions => {
|
173
173
|
:post => {
|
174
|
-
:submit => 'Custom Submit
|
174
|
+
:submit => 'Custom Submit {{model}}'
|
175
175
|
}
|
176
176
|
}
|
177
177
|
}
|
@@ -210,7 +210,7 @@ describe 'SemanticFormBuilder#commit_button' do
|
|
210
210
|
describe 'when no explicit label is provided' do
|
211
211
|
describe 'when no I18n-localized label is provided' do
|
212
212
|
before do
|
213
|
-
::I18n.backend.store_translations :en, :formtastic => {:create => 'Create
|
213
|
+
::I18n.backend.store_translations :en, :formtastic => {:create => 'Create {{model}}'}
|
214
214
|
end
|
215
215
|
|
216
216
|
after do
|
@@ -245,7 +245,7 @@ describe 'SemanticFormBuilder#commit_button' do
|
|
245
245
|
:formtastic => {
|
246
246
|
:actions => {
|
247
247
|
:post => {
|
248
|
-
:create => 'Custom Create
|
248
|
+
:create => 'Custom Create {{model}}'
|
249
249
|
}
|
250
250
|
}
|
251
251
|
}
|
@@ -284,7 +284,7 @@ describe 'SemanticFormBuilder#commit_button' do
|
|
284
284
|
describe 'when no explicit label is provided' do
|
285
285
|
describe 'when no I18n-localized label is provided' do
|
286
286
|
before do
|
287
|
-
::I18n.backend.store_translations :en, :formtastic => {:update => 'Save
|
287
|
+
::I18n.backend.store_translations :en, :formtastic => {:update => 'Save {{model}}'}
|
288
288
|
end
|
289
289
|
|
290
290
|
after do
|
@@ -319,7 +319,7 @@ describe 'SemanticFormBuilder#commit_button' do
|
|
319
319
|
:formtastic => {
|
320
320
|
:actions => {
|
321
321
|
:post => {
|
322
|
-
:update => 'Custom Save
|
322
|
+
:update => 'Custom Save {{model}}'
|
323
323
|
}
|
324
324
|
}
|
325
325
|
}
|
data/spec/i18n_spec.rb
CHANGED
@@ -26,11 +26,11 @@ describe 'Formtastic::I18n' do
|
|
26
26
|
@formtastic_strings = {
|
27
27
|
:yes => 'Default Yes',
|
28
28
|
:no => 'Default No',
|
29
|
-
:create => 'Default Create
|
30
|
-
:update => 'Default Update
|
29
|
+
:create => 'Default Create {{model}}',
|
30
|
+
:update => 'Default Update {{model}}',
|
31
31
|
:custom_scope => {
|
32
32
|
:duck => 'Duck',
|
33
|
-
:duck_pond => '
|
33
|
+
:duck_pond => '{{ducks}} ducks in a pond'
|
34
34
|
}
|
35
35
|
}
|
36
36
|
::I18n.backend.store_translations :en, :formtastic => @formtastic_strings
|
@@ -71,7 +71,7 @@ describe 'Formtastic::I18n' do
|
|
71
71
|
|
72
72
|
it "should use default strings" do
|
73
73
|
(::Formtastic::I18n::DEFAULT_VALUES.keys).each do |key|
|
74
|
-
::Formtastic::I18n.t(key, :model => '
|
74
|
+
::Formtastic::I18n.t(key, :model => '{{model}}').should == ::Formtastic::I18n::DEFAULT_VALUES[key]
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 10
|
9
|
+
version: 0.9.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Justin French
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-26 00:00:00 +10:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|