Fix ambiguity in i18n lookup, closes #384.

This commit is contained in:
José Valim 2011-12-08 09:44:08 +01:00
parent 031e3324ca
commit 259640e4cb
3 changed files with 5 additions and 5 deletions

View File

@ -120,7 +120,7 @@ module SimpleForm
# simple_form.{namespace}.{model}.{nested}.{attribute}
# simple_form.{namespace}.{nested}.{action}.{attribute}
# simple_form.{namespace}.{nested}.{attribute}
# simple_form.{namespace}.{attribute}
# simple_form.{namespace}.defaults.{attribute}
#
# Example:
#
@ -144,7 +144,7 @@ module SimpleForm
lookups << :"#{joined_model_names}.#{lookup_action}.#{reflection_or_attribute_name}"
lookups << :"#{joined_model_names}.#{reflection_or_attribute_name}"
end
lookups << :"#{attribute_name}" unless reflection
lookups << :"defaults.#{attribute_name}" unless reflection
lookups << default
I18n.t(lookups.shift, :scope => :"simple_form.#{namespace}", :default => lookups).presence

View File

@ -73,7 +73,7 @@ class IsolatedLabelTest < ActionView::TestCase
end
test 'input should use i18n based only on attribute to lookup translation' do
store_translations(:en, :simple_form => { :labels => { :age => 'Idade' } } ) do
store_translations(:en, :simple_form => { :labels => { :defaults => {:age => 'Idade'} } } ) do
with_label_for @user, :age, :integer
assert_select 'label[for=user_age]', /Idade/
end
@ -81,7 +81,7 @@ class IsolatedLabelTest < ActionView::TestCase
test 'input should not use i18n label if translate is false' do
swap SimpleForm, :translate_labels => false do
store_translations(:en, :simple_form => { :labels => { :age => 'Idade' } } ) do
store_translations(:en, :simple_form => { :labels => { :defaults => {:age => 'Idade'} } } ) do
with_label_for @user, :age, :integer
assert_select 'label[for=user_age]', /Age/
end

View File

@ -90,7 +90,7 @@ class HintTest < ActionView::TestCase
test 'hint should use i18n just with attribute to lookup translation' do
store_translations(:en, :simple_form => { :hints => {
:name => 'Content of this input will be downcased...'
:defaults => {:name => 'Content of this input will be downcased...'}
} }) do
with_hint_for @user, :name
assert_select 'span.hint', 'Content of this input will be downcased...'