Skip to content

Instantly share code, notes, and snippets.

@f440
Created December 20, 2013 07:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f440/8051614 to your computer and use it in GitHub Desktop.
Save f440/8051614 to your computer and use it in GitHub Desktop.
forwardable
require 'sinatra/base'
require 'forwardable'
class I18n
def self.t(s); "I18n.t(#{s})"; end
def self.l(s); "I18n.l(#{s})"; end
end
class App < Sinatra::Base
extend Forwardable
helpers do
def_delegators I18n, :t, :l
end
get '/t/:s' do
t(params[:s])
end
get '/l/:s' do
l(params[:s])
end
end
run App.new
# Usage:
# $ rackup
#
# $ curl http://localhost:9292/t/hogehoge #=>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment