File: helloerb1.cgi

package info (click to toggle)
libgettext-ruby 1.7.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,892 kB
  • ctags: 1,198
  • sloc: ruby: 6,738; ansic: 67; makefile: 38; sql: 14; sh: 6
file content (51 lines) | stat: -rwxr-xr-x 1,028 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env ruby
=begin
  helloerb1.cgi - Sample script for CGI/ERB

  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
begin
  require 'rubygems'
rescue LoadError
end

require 'gettext/cgi'
require 'gettext/erb'

class SimpleContainer1
  include GetText::ErbContainer

  def initialize(domainname, domainpath = nil, locale = nil, charset = nil)
    bindtextdomain(domainname, domainpath, locale)
    @domainname = domainname
  end

  def description
    _("Sample script for CGI/ERB (UTF-8).")
  end

  def to_html(path)
    eval_file(path)
  end
end


GetText.output_charset = "UTF-8"

print "Content-type:text/html; charset=UTF-8\n\n"

con = SimpleContainer1.new("helloerb1", "locale")

if GetText.cgi["other"] == "true"
  print con.to_html("other.rhtml")
else
  print con.to_html("helloerb.rhtml")
end