mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Pluralize namespace for consistency
This commit is contained in:
parent
a7c3d52072
commit
ef81ffe713
2 changed files with 16 additions and 14 deletions
|
@ -105,11 +105,13 @@ module SimpleForm
|
|||
def translate_option(options, key)
|
||||
return unless options[key].is_a? Symbol
|
||||
|
||||
namespace = key.to_s.pluralize
|
||||
|
||||
options[key] = case options[key]
|
||||
when :translate, :t
|
||||
translate(key, true)
|
||||
translate(namespace, true)
|
||||
else
|
||||
I18n.t(options[key], scope: :"simple_form.#{key}")
|
||||
I18n.t(options[key], scope: :"simple_form.#{namespace}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -97,7 +97,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should translate include blank when set to :translate' do
|
||||
store_translations(:en, :simple_form => { :include_blank => { :user => {
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => :translate
|
||||
|
@ -106,7 +106,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should translate include blank when set to :t' do
|
||||
store_translations(:en, :simple_form => { :include_blank => { :user => {
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => :t
|
||||
|
@ -115,7 +115,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should translate include blank with a particular key' do
|
||||
store_translations(:en, :simple_form => { :include_blank => {
|
||||
store_translations(:en, :simple_form => { :include_blanks => {
|
||||
:age => 'Rather not say',
|
||||
:user => { :age => 'Should be overridden' }
|
||||
} } ) do
|
||||
|
@ -125,7 +125,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should not translate include blank when set to a string' do
|
||||
store_translations(:en, :simple_form => { :include_blank => { :user => {
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => 'Young at heart'
|
||||
|
@ -134,7 +134,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should not translate include blank when automatically set' do
|
||||
store_translations(:en, :simple_form => { :include_blank => { :user => {
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30
|
||||
|
@ -143,7 +143,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should not translate include blank when set to true' do
|
||||
store_translations(:en, :simple_form => { :include_blank => { :user => {
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => true
|
||||
|
@ -152,7 +152,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should not translate include blank when set to false' do
|
||||
store_translations(:en, :simple_form => { :include_blank => { :user => {
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => false
|
||||
|
@ -176,7 +176,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should translate prompt when set to :translate' do
|
||||
store_translations(:en, :simple_form => { :prompt => { :user => {
|
||||
store_translations(:en, :simple_form => { :prompts => { :user => {
|
||||
:age => 'Select age:'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :prompt => :translate
|
||||
|
@ -185,7 +185,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should translate prompt when set to :t' do
|
||||
store_translations(:en, :simple_form => { :prompt => { :user => {
|
||||
store_translations(:en, :simple_form => { :prompts => { :user => {
|
||||
:age => 'Select age:'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :prompt => :t
|
||||
|
@ -194,7 +194,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should translate prompt with a particular key' do
|
||||
store_translations(:en, :simple_form => { :prompt => {
|
||||
store_translations(:en, :simple_form => { :prompts => {
|
||||
:age => 'Select age:',
|
||||
:user => { :age => 'Should be overridden' }
|
||||
} } ) do
|
||||
|
@ -204,7 +204,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should not translate prompt when set to a string' do
|
||||
store_translations(:en, :simple_form => { :prompt => { :user => {
|
||||
store_translations(:en, :simple_form => { :prompts => { :user => {
|
||||
:age => 'Select age:'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :prompt => 'Do it:'
|
||||
|
@ -213,7 +213,7 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should not translate prompt when set to false' do
|
||||
store_translations(:en, :simple_form => { :prompt => { :user => {
|
||||
store_translations(:en, :simple_form => { :prompts => { :user => {
|
||||
:age => 'Select age:'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :prompt => false
|
||||
|
|
Loading…
Reference in a new issue