Permalink
Browse files

i18n fix II: "The {{key}} interpolation syntax in I18n messages is de…

…precated. Please use %{key} instead."
  • Loading branch information...
1 parent 5469c79 commit 49b45f6ad8578607c8a5ecc58695e2cf834ac577 @HP HP committed with mjonuschat May 21, 2010
Showing with 20 additions and 20 deletions.
  1. +2 −2 README.textile
  2. +8 −8 lib/formtastic/i18n.rb
  3. +6 −6 spec/commit_button_spec.rb
  4. +4 −4 spec/i18n_spec.rb
View
@@ -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
@@ -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
@@ -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
@@ -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 49b45f6

Please sign in to comment.