public
Last active

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13
module Rack
class LocaleSetter
def initialize app
@app = app
end
 
def call env
locale = env["HTTP_HOST"].match(/^[a-z]{2}(?=\.)/)
I18n.locale = locale ? locale.to_s : 'es'
@app.call env
end
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.