Hi there!
There is still no lazy translations for models. Do you want this
functionality?
I''ve got this module and can prepare a PR
module ActiveModel
module TranslationHelper
extend ActiveSupport::Concern
module ClassMethods
def translate(key, options = {})
return I18n.translate(key, options) unless key.to_s.first ==
''.''
strings_scope = "#{i18n_scope}.strings"
defaults = lookup_ancestors.map do |klass|
:"#{strings_scope}.#{klass.model_name.i18n_key}.#{key}"
end
defaults << :"strings.#{key}"
defaults << options.delete(:default) if options[:default]
options[:default] = defaults
I18n.translate(defaults.shift, options)
end
alias :t :translate
end
def translate(*args)
self.class.translate(*args)
end
alias :t :translate
end
end
ActiveRecord::Base.send :include, ActiveModel::TranslationHelper
Max
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.