Skip to content

Commit

Permalink
fix nested object i18n scopes order
Browse files Browse the repository at this point in the history
add failing spec for issue formtastic#613
  • Loading branch information
crystalin authored and James Conroy-Finn committed Jan 27, 2012
1 parent ffa79ba commit 5348bac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/formtastic/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ module I18n
DEFAULT_VALUES = YAML.load_file(File.expand_path("../../locale/en.yml", __FILE__))["en"]["formtastic"].freeze
SCOPES = [
'%{model}.%{nested_model}.%{action}.%{attribute}',
'%{model}.%{action}.%{attribute}',
'%{model}.%{nested_model}.%{attribute}',
'%{model}.%{attribute}',
'%{nested_model}.%{action}.%{attribute}',
'%{nested_model}.%{attribute}',
'%{model}.%{action}.%{attribute}',
'%{model}.%{attribute}',
'%{attribute}'
]

Expand Down
11 changes: 11 additions & 0 deletions spec/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@
output_buffer.should have_tag("form label", /Hello author name!/)
end
end

it 'should be able to translate nested objects with nested object translations' do
with_config :i18n_lookups_by_default, true do
concat(semantic_form_for(@new_post) do |builder|
builder.semantic_fields_for(:project) do |f|
concat(f.input(:title))
end
end)
output_buffer.should have_tag("form label", /Hello project!/)
end
end

it 'should be able to translate nested forms with top level translations' do
with_config :i18n_lookups_by_default, true do
Expand Down

0 comments on commit 5348bac

Please sign in to comment.