Skip to content

Commit

Permalink
Revert "Reverting two i18n patches pulled in from the rails3 branch w…
Browse files Browse the repository at this point in the history
…hich are not compatible with Rails 2.3.x."

This reverts commit 1469b53.
  • Loading branch information
mjonuschat committed May 29, 2010
1 parent 20a7fa4 commit 743b26b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.textile
Expand Up @@ -337,7 +337,7 @@ Formtastic supports localized *labels*, *hints*, *legends*, *actions* using the
title: "Choose a good title for you post."
body: "Write something inspiring here."
actions:
create: "Create my {{model}}"
create: "Create my %{model}"
update: "Save changes"
dummie: "Launch!"
</pre>
Expand All @@ -354,7 +354,7 @@ Formtastic supports localized *labels*, *hints*, *legends*, *actions* using the
<%= form.input :section %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
<% end %>
<% form.buttons do %>
<%= form.commit_button %> # => "Create my {{model}}"
<%= form.commit_button %> # => "Create my %{model}"
<% end %>
<% end %>
</pre>
Expand Down
14 changes: 7 additions & 7 deletions lib/formtastic.rb
Expand Up @@ -1606,9 +1606,9 @@ def humanized_attribute_name(method) #:nodoc:
#
# Lookup priority:
#
# 'formtastic.{{type}}.{{model}}.{{action}}.{{attribute}}'
# 'formtastic.{{type}}.{{model}}.{{attribute}}'
# 'formtastic.{{type}}.{{attribute}}'
# 'formtastic.%{type}.%{model}.%{action}.%{attribute}'
# 'formtastic.%{type}.%{model}.%{attribute}'
# 'formtastic.%{type}.%{attribute}'
#
# Example:
#
Expand All @@ -1633,10 +1633,10 @@ def localized_string(key, value, type, options = {}) #:nodoc:

defaults = ::Formtastic::I18n::SCOPES.collect do |i18n_scope|
i18n_path = i18n_scope.dup
i18n_path.gsub!('{{action}}', action_name)
i18n_path.gsub!('{{model}}', model_name)
i18n_path.gsub!('{{nested_model}}', nested_model_name) unless nested_model_name.nil?
i18n_path.gsub!('{{attribute}}', attribute_name)
i18n_path.gsub!('%{action}', action_name)
i18n_path.gsub!('%{model}', model_name)
i18n_path.gsub!('%{nested_model}', nested_model_name) unless nested_model_name.nil?
i18n_path.gsub!('%{attribute}', attribute_name)
i18n_path.gsub!('..', '.')
i18n_path.to_sym
end
Expand Down
16 changes: 8 additions & 8 deletions lib/formtastic/i18n.rb
Expand Up @@ -6,16 +6,16 @@ module I18n
:required => 'required',
:yes => 'Yes',
:no => 'No',
:create => 'Create {{model}}',
:update => 'Update {{model}}'
:create => 'Create %{model}',
:update => 'Update %{model}'
}.freeze
SCOPES = [
'{{model}}.{{nested_model}}.{{action}}.{{attribute}}',
'{{model}}.{{action}}.{{attribute}}',
'{{model}}.{{nested_model}}.{{attribute}}',
'{{model}}.{{attribute}}',
'{{nested_model}}.{{attribute}}',
'{{attribute}}'
'%{model}.%{nested_model}.%{action}.%{attribute}',
'%{model}.%{action}.%{attribute}',
'%{model}.%{nested_model}.%{attribute}',
'%{model}.%{attribute}',
'%{nested_model}.%{attribute}',
'%{attribute}'
]

class << self
Expand Down
12 changes: 6 additions & 6 deletions spec/commit_button_spec.rb
Expand Up @@ -147,7 +147,7 @@
describe 'when no explicit label is provided' do
describe 'when no I18n-localized label is provided' do
before do
::I18n.backend.store_translations :en, :formtastic => {:submit => 'Submit {{model}}'}
::I18n.backend.store_translations :en, :formtastic => {:submit => 'Submit %{model}'}
end

after do
Expand Down Expand Up @@ -183,7 +183,7 @@
:formtastic => {
:actions => {
:post => {
:submit => 'Custom Submit {{model}}'
:submit => 'Custom Submit %{model}'
}
}
}
Expand Down Expand Up @@ -225,7 +225,7 @@
describe 'when no explicit label is provided' do
describe 'when no I18n-localized label is provided' do
before do
::I18n.backend.store_translations :en, :formtastic => {:create => 'Create {{model}}'}
::I18n.backend.store_translations :en, :formtastic => {:create => 'Create %{model}'}
end

after do
Expand Down Expand Up @@ -261,7 +261,7 @@
:formtastic => {
:actions => {
:post => {
:create => 'Custom Create {{model}}'
:create => 'Custom Create %{model}'
}
}
}
Expand Down Expand Up @@ -303,7 +303,7 @@
describe 'when no explicit label is provided' do
describe 'when no I18n-localized label is provided' do
before do
::I18n.backend.store_translations :en, :formtastic => {:update => 'Save {{model}}'}
::I18n.backend.store_translations :en, :formtastic => {:update => 'Save %{model}'}
end

after do
Expand Down Expand Up @@ -340,7 +340,7 @@
:formtastic => {
:actions => {
:post => {
:update => 'Custom Save {{model}}'
:update => 'Custom Save %{model}'
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions spec/i18n_spec.rb
Expand Up @@ -26,11 +26,11 @@
@formtastic_strings = {
:yes => 'Default Yes',
:no => 'Default No',
:create => 'Default Create {{model}}',
:update => 'Default Update {{model}}',
:create => 'Default Create %{model}',
:update => 'Default Update %{model}',
:custom_scope => {
:duck => 'Duck',
:duck_pond => '{{ducks}} ducks in a pond'
:duck_pond => '%{ducks} ducks in a pond'
}
}
::I18n.backend.store_translations :en, :formtastic => @formtastic_strings
Expand Down Expand Up @@ -71,7 +71,7 @@

it "should use default strings" do
(::Formtastic::I18n::DEFAULT_VALUES.keys).each do |key|
::Formtastic::I18n.t(key, :model => '{{model}}').should == ::Formtastic::I18n::DEFAULT_VALUES[key]
::Formtastic::I18n.t(key, :model => '%{model}').should == ::Formtastic::I18n::DEFAULT_VALUES[key]
end
end

Expand Down

0 comments on commit 743b26b

Please sign in to comment.