Class: I18n::MissingTranslations

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/missing_translations.rb,
lib/i18n/missing_translations/log.rb,
lib/i18n/missing_translations/handler.rb,
lib/i18n/missing_translations/version.rb

Defined Under Namespace

Modules: Handler Classes: Log

Constant Summary collapse

VERSION =
"0.0.2"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, filename = nil) ⇒ MissingTranslations

Returns a new instance of MissingTranslations.



19
20
21
22
# File 'lib/i18n/missing_translations.rb', line 19

def initialize(app, filename = nil)
  @app = app
  @filename = filename || "#{locale_dir}/missing_translations.yml"
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



17
18
19
# File 'lib/i18n/missing_translations.rb', line 17

def app
  @app
end

#filenameObject (readonly)

Returns the value of attribute filename.



17
18
19
# File 'lib/i18n/missing_translations.rb', line 17

def filename
  @filename
end

Instance Method Details

#call(*args) ⇒ Object



24
25
26
27
# File 'lib/i18n/missing_translations.rb', line 24

def call(*args)
  log.read(filename)
  app.call(*args).tap { log.write(filename) }
end

#locale_dirObject



33
34
35
# File 'lib/i18n/missing_translations.rb', line 33

def locale_dir
  File.directory?("#{Dir.pwd}/config/locales") ? "#{Dir.pwd}/config/locales" : Dir.pwd
end

#logObject



29
30
31
# File 'lib/i18n/missing_translations.rb', line 29

def log
  I18n.missing_translations
end