Created
December 20, 2013 07:43
-
-
Save f440/8051614 to your computer and use it in GitHub Desktop.
forwardable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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