On Wed, Mar 30, 2011 at 08:18:45AM -0700, John Firebaugh wrote: > On Wed, Mar 30, 2011 at 5:47 AM, Rodrigo Rosenfeld Rosas <[email protected] > > wrote: > > > This issue started here: > > > > > > https://rails.lighthouseapp.com/projects/8994/tickets/3768-patch-add-full_message-option-to-validations#ticket-3768-69 > > > > Then José Valim thought it was a bug and asked me to create another issue: > > > > https://rails.lighthouseapp.com/projects/8994/tickets/5572 > > > > Then, this issue was created: > > > > https://rails.lighthouseapp.com/projects/8994/tickets/6448 > > > > Then Valim reverted 5572. > > > > Now I know that my i18n locale files should be written like this: > > > > pt-BR: > > activerecord: > > errors: > > models: > > my_module/order: > > attributes: > > amount: > > not_a_number: deve ser um número > > > > I think there will be no more confusing regarding this behavior now we all > > know what to expect. Maybe there is some documentation missing, regarding > > modules and i18n keys. > > > > There are two problems here. > > The first problem is that the public API changed between 3.0.5 and > 3.0.6.rc1: the i18n_key method was removed. This is a breaking change for > applications (mine included) that used this method themselves. To fix this, > the method should be restored, with either the 3.0.5 definition or a new > definition (depending on the solution for the second, more difficult > problem). > > The second problem is that we now have two competing conventions for where > to place translations for attributes of nested models. 3.0.0-3.0.1 used one > convention ('module/model'), 3.0.2-3.0.5 used another ('module.model'), and > now in 3.0.6 is reverting to the first convention. The change from 3.0.1 to > 3.0.2 broke all translations which followed the original convention, and for > users on 3.0.2-3.0.5, the change from 3.0.5 to 3.0.6 will break them again. > In order to avoid this breaking change, I suggest that we keep > 'module/model' as the documented preferred convention, but for > compatibility, try 'module.model' if no translation is found under > 'module/model'.
Just so we're on the same page, we would expect this test to pass:
diff --git a/activemodel/test/cases/translation_test.rb
b/activemodel/test/cases/translation_test.rb
index 1db63e1..0584606 100644
--- a/activemodel/test/cases/translation_test.rb
+++ b/activemodel/test/cases/translation_test.rb
@@ -39,6 +39,15 @@ class ActiveModelI18nTests < ActiveModel::TestCase
assert_equal 'person gender attribute',
Person::Gender.human_attribute_name('attribute')
end
+ def
test_translated_model_attributes_with_attribute_matching_namespaced_model_name_and_dot
+ assert_deprecated do
+ I18n.backend.store_translations 'en', :activemodel => {:attributes =>
{:person => {:gender => 'person gender'}, :"person.gender" => {:attr
+ end
+
+ assert_equal 'person gender', Person.human_attribute_name('gender')
+ assert_equal 'person gender attribute',
Person::Gender.human_attribute_name('attribute')
+ end
+
def test_translated_model_names
I18n.backend.store_translations 'en', :activemodel => {:models => {:person
=> 'person model'} }
assert_equal 'person model', Person.model_name.human
If that's true, I'll try to get another RC out tonight. If not, we may have to
wait for a few days as I'll be on vacation. :-(
--
Aaron Patterson
http://tenderlovemaking.com/
pgpopV71KyjCi.pgp
Description: PGP signature
