#!/usr/bin/env ruby =begin cookie.cgi - Set a selected locale to the cookie of WWW Browser. Set UTF-8 forcely as output charset. Recommanded to set UTF-8 forcely because some web browser doesn't send HTTP_ACCEPT_CHARSET correctly. Copyright (C) 2005 Masao Mutoh You may redistribute it and/or modify it under the same license terms as Ruby. =end # gettext/cgi support CGI. begin require 'rubygems' rescue LoadError end require 'gettext/cgi' include GetText # Configure GetText first. set_output_charset("UTF-8") bindtextdomain("main", "locale") lang = GetText.cgi['lang'] lang = "en" unless lang.size > 0 # # CGI part # print "Set-Cookie:lang=#{lang}\n" print "Content-type:text/html; charset=UTF-8\n\n" puts %Q[
Copyright (C) 2005 Masao Mutoh