Translation helpers for models with lazy lookup

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