File: hello_rack.rb

package info (click to toggle)
ruby-locale 2.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 452 kB
  • sloc: ruby: 3,285; makefile: 9
file content (16 lines) | stat: -rw-r--r-- 429 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'rubygems'
require 'rack'
require 'locale_rack'
 
class HelloRackApp
  include Locale::Rack

  def call(env)
    req = Rack::Request.new(env)
    init_locale(env, req)
    str = "Language tag candidates of your request order by the priority:\n\n"
    str += Locale.candidates(:type => :rfc).map{|v| v.inspect + "\n"}.join
    [200, {"Content-Type" => "text/plain", "Content-Length" => str.length.to_s}, [str]]
  end
end