Class: Faalis::I18n::MissingKeyHandler

Inherits:
I18n::ExceptionHandler
  • Object
show all
Defined in:
lib/faalis/i18n.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) call(exception, locale, key, options)



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/faalis/i18n.rb', line 108

def call(exception, locale, key, options)
  if exception.is_a?(::I18n::MissingTranslation)
    create_key_cache(locale, key)
    #super
    puts '<<<<<<<<<<<<<<<', key , locale, options
    #"translation missing: #{locale}.#{key}"
    nil
  else
    super
  end
end

- (Object) create_key_cache(locale, key)



100
101
102
103
104
105
106
# File 'lib/faalis/i18n.rb', line 100

def create_key_cache(locale, key)
  locale_dir = "#{Rails.root}/tmp/i18n/#{locale}"
  key_file   = "#{locale_dir}/#{key}"

  FileUtils.mkdir_p locale_dir
  FileUtils.touch [key_file]
end