Sha256: e72f0eedf07d7f19f065bcb7064d941e5418ad532182d6595183504a9f8f9570

Contents?: true

Size: 1005 Bytes

Versions: 15

Compression:

Stored size: 1005 Bytes

Contents

class GettextSimpleRails::Translators::DeviseTranslator
  def detected?
    return ::Kernel.const_defined?("Devise")
  end
  
  def translations
    devise_gem_path = Gem.loaded_specs['devise'].full_gem_path
    devise_yml_translation_file = "#{devise_gem_path}/config/locales/en.yml"
    translations = YAML.load(File.read(devise_yml_translation_file))
    
    # Add failure translations for all devise models.
    devise_models.each do |clazz|
      translations["en"]["devise"]["failure"][StringCases.camel_to_snake(clazz.name)] = translations["en"]["devise"]["failure"].clone
    end
    
    return translations["en"]
  end
  
private
  
  def devise_models
    classes = []
    
    ::Rails.application.eager_load!
    
    ::Object.constants.each do |clazz|
      clazz = clazz.to_s.constantize
      next unless clazz.class == Class
      next unless clazz < ActiveRecord::Base
      next unless clazz.respond_to?(:devise_modules)
      classes << clazz
    end
    
    return classes
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gettext_simple_rails-0.0.19 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.17 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.16 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.15 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.14 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.13 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.12 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.11 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.10 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.9 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.8 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.7 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.6 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.5 lib/gettext_simple_rails/translators/devise_translator.rb
gettext_simple_rails-0.0.4 lib/gettext_simple_rails/translators/devise_translator.rb