lib/i18n/js/middleware.rb
# Check if translations should be regenerated.
# ONLY REGENERATE when these conditions are met:
#
# # Cache file doesn't exist
# # Translations and cache size are different (files were removed/added)
# # Translation file has been updated
#
Check if translations should be regenerated.
ONLY REGENERATE when these conditions are met.

Cache file doesn't exist
Translations and cache size are different (files were removed/added)
Translation file has been updated
Check if translations should be regenerated . ONLY REGENERATE when these conditions are met . Cache file doesn ' t exist Translations and cache size are different ( files were removed / added ) Translation file has been updated
def verify_locale_files!
        valid_cache = []
        new_cache = {}
        valid_cache.push cache_path.exist?
        valid_cache.push ::I18n.load_path.uniq.size == cache.size
        ::I18n.load_path.each do |path|
          changed_at = File.mtime(path).to_i
          valid_cache.push changed_at == cache[path]
          new_cache[path] = changed_at
        end
        return if valid_cache.all?
        File.open(cache_path, "w+") do |file|
          file << new_cache.to_yaml
        end
        ::I18n::JS.export
      end
def verify_locale_files! valid_cache = [ ] new_cache = { } valid_cache . push cache_path . exist? valid_cache . push :: I18n . load_path . uniq . size == cache . size :: I18n . load_path . each do | path | changed_at = File . mtime ( path ) . to_i valid_cache . push changed_at == cache [ path ] new_cache [ path ] = changed_at end return if valid_cache . all? File . open ( cache_path , "w+" ) do | file | file << new_cache . to_yaml end :: I18n :: JS . export end
Check if translations should be regenerated.
Check if translations should be regenerated .