I have a Contact model that is a non activerecord model. I can use the
validation thanks to Rails3, but I do not in which section of
en.yml/de.yml I should localize the attributes of my Contact model.
fipa
February 8, 2011, 11:45am
2
The scope is not under activerecord, but activemodel, which you can
change:
# # => "My attribute"
#
# This also provides the required class methods for hooking into the
# \Rails internationalization API, including being able to define a
# class-based +i18n_scope+ and +lookup_ancestors+ to find translations in
# parent classes.
module Translation
include ActiveModel::Naming
# Returns the +i18n_scope+ for the class. Override if you want custom lookup.
def i18n_scope
:activemodel
end
# When localizing a string, it goes through the lookup returned by this
# method, which is used in ActiveModel::Name#human,
# ActiveModel::Errors#full_messages and
# ActiveModel::Translation#human_attribute_name.
def lookup_ancestors
ancestors.select { |x| x.respond_to?(:model_name) }
end
Hope this helps
Cheers, iain
fipa
February 9, 2011, 3:05pm
3
Iain H. wrote in post #980254:
The scope is not under activerecord, but activemodel, which you can
change:
# # => "My attribute"
#
# This also provides the required class methods for hooking into the
# \Rails internationalization API, including being able to define a
# class-based +i18n_scope+ and +lookup_ancestors+ to find translations in
# parent classes.
module Translation
include ActiveModel::Naming
# Returns the +i18n_scope+ for the class. Override if you want custom lookup.
def i18n_scope
:activemodel
end
# When localizing a string, it goes through the lookup returned by this
# method, which is used in ActiveModel::Name#human,
# ActiveModel::Errors#full_messages and
# ActiveModel::Translation#human_attribute_name.
def lookup_ancestors
ancestors.select { |x| x.respond_to?(:model_name) }
end
Hope this helps
Cheers, iain
Thank you!
fipa
February 13, 2011, 5:33pm
4
2011/2/9 Fernando P. [email protected] :