Sha256: 26d2f9db67419b06379fb807aa1ca60154b73af83b9b180e91846e1588679434
Contents?: true
Size: 715 Bytes
Versions: 6
Compression:
Stored size: 715 Bytes
Contents
# frozen_string_literal: true module WebTranslateIt # Class to automatically fetch the last translations from Web Translate It # for every page requested. # This can be used as a rack middleware. # Implementation example: # # # in config/environment.rb: # config.middleware.use "WebTranslateIt::AutoFetch" # class AutoFetch def initialize(app) @app = app end def call(env) update_translations if valid_request?(env) @app.call(env) end private def update_translations WebTranslateIt.fetch_translations I18n.reload! end def valid_request?(env) env['PATH_INFO'] !~ /\.(js|css|jpeg|jpg|gif|png|woff)$/ end end end
Version data entries
6 entries across 6 versions & 1 rubygems