Sha256: f912e0902139397b2305eab4ec2399b3a98f44427fc07284b100036f60ee8d8e
Contents?: true
Size: 700 Bytes
Versions: 28
Compression:
Stored size: 700 Bytes
Contents
# encoding: utf-8 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
28 entries across 28 versions & 1 rubygems