Skip to content
Browse files

Reverting two i18n patches pulled in from the rails3 branch which are…

… not compatible with Rails 2.3.x.

Specs pass without deprecation warnings, and the relevant commits in Rails (13867a3 and 9bd91b0) seem to be in master, but not in the v2.3.8 branch.

Revert "i18n fix: "The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead.""
This reverts commit .

Revert "i18n fix II: "The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead.""
This reverts commit 49b45f6.
  • Loading branch information...
1 parent 7ea72eb commit 1469b533cb7a5d0e54ee0a845a88b72576b62885 @justinfrench committed May 26, 2010
Showing with 27 additions and 27 deletions.
  1. +2 −2 README.textile
  2. +7 −7 lib/formtastic.rb
  3. +8 −8 lib/formtastic/i18n.rb
  4. +6 −6 spec/commit_button_spec.rb
  5. +4 −4 spec/i18n_spec.rb
View
4 README.textile
@@ -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>
@@ -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>
View
14 lib/formtastic.rb
@@ -1595,9 +1595,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:
#
@@ -1622,10 +1622,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
View
16 lib/formtastic/i18n.rb
@@ -7,16 +7,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
View
12 spec/commit_button_spec.rb
@@ -136,7 +136,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
@@ -171,7 +171,7 @@
:formtastic => {
:actions => {
:post => {
- :submit => 'Custom Submit %{model}'
+ :submit => 'Custom Submit {{model}}'
}
}
}
@@ -210,7 +210,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
@@ -245,7 +245,7 @@
:formtastic => {
:actions => {
:post => {
- :create => 'Custom Create %{model}'
+ :create => 'Custom Create {{model}}'
}
}
}
@@ -284,7 +284,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
@@ -319,7 +319,7 @@
:formtastic => {
:actions => {
:post => {
- :update => 'Custom Save %{model}'
+ :update => 'Custom Save {{model}}'
}
}
}
View
8 spec/i18n_spec.rb
@@ -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
@@ -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

0 comments on commit 1469b53

Please sign in to comment.
Something went wrong with that request. Please try again.