#!/usr/bin/env ruby =begin hello.cgi - Sample script for CGI 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 $:.insert(0, "../../lib") # gettext/cgi support CGI. begin require 'rubygems' rescue LoadError end require 'gettext/cgi' include GetText set_cgi(CGI.new) print "Content-type:text/html; charset=UTF-8\n\n" # Configure GetText first. set_output_charset("UTF-8") bindtextdomain("main", "locale") langs = ["en"] + Dir.glob("locale/*").collect{|item| File.basename(item)} langs.sort! urls = [ ["helloerb1.cgi", N_("an ERB/CGI sample (UTF-8).")], ["helloerb1.cgi?other=true", N_("an ERB/CGI sample (UTF-8). This sample uses the same container as sample 1 but has a different rhtml file.")], ["helloerb2.cgi", N_("an ERB/CGI sample (Auto-Detect charset).")] ] # # CGI part # puts %Q[
" + _("Supported Locales:") + "[#{langs.join(", ")}]
" puts "" + _('Click one of the link below, and then click "Auto-Detect a locale from the WWW browser" samples.') + "
" puts "] + _("index.cgi is also a Ruby-GetText sample script using CGI(not ERB).")+ %Q[
Copyright (C) 2005-2008 Masao Mutoh