module I18n::Backend::CacheFile
def load_file(filename)
Track loaded translation files in the `i18n.load_file` scope,
def load_file(filename) initialized = !respond_to?(:initialized?) || initialized? key = I18n::Backend::Flatten.escape_default_separator(normalized_path(filename)) old_mtime, old_digest = initialized && lookup(:i18n, key, :load_file) return if (mtime = File.mtime(filename).to_i) == old_mtime || (digest = OpenSSL::Digest::SHA256.file(filename).hexdigest) == old_digest super store_translations(:i18n, load_file: { key => [mtime, digest] }) end
def normalized_path(file)
def normalized_path(file) return file unless path_roots path = path_roots.find(&file.method(:start_with?)) || raise(InvalidLocaleData.new(file, 'outside expected path roots')) file.sub(path, path_roots.index(path).to_s) end