<body>

Caiwangqin's blog

Focus on Web2.0, Business, Architecture, Agile, Technic and beyond…

Ruby on Rails 根据浏览器语言自动选择站点语言

2007年6月12日 星期二

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


标签:

posted by Caiwangqin, 上午3:12

<< 主页