Jun
12
Filed under: RubyonRails / Ruby
stephen kung 发来的解决方案:
def index
@header = request.env[’HTTP_ACCEPT_LANGUAGE’]
case @header
when /zh-cn.*/
@location=’china’
when /en-us.*/
@location=’english’
else
@location=’english’
end
render :text => @location
end
read more:
http://wiki.rubyonrails.org/rails/pages/VariablesInRequestEnv
Tags:





No Responses
Leave a Response