Method: Locale.init

Defined in:
lib/locale.rb

.init(opts = {}) ⇒ Object

Initialize Locale library. Usually, you don’t need to call this directly, because this is called when Locale’s methods are called.

If you use this library with CGI or the kind of CGI. You need to call Locale.init(:driver => :cgi).

For Framework designers/programers:

If your framework is for WWW, call this once like: Locale.init(:driver => :cgi).

To Application programers:

If your framework doesn’t use ruby-locale and the application is for WWW, call this once like: Locale.init(:driver => :cgi).

To Library authors:

Don’t call this, even if your application is only for WWW.

  • opts: Options as a Hash.

    • :driver - The driver. :cgi if you use Locale module with CGI, nil if you use system locale.

      (ex) Locale.init(:driver => :cgi)
      


67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/locale.rb', line 67

def init(opts = {})
  if opts[:driver]
    require_driver opts[:driver]
  else
    if /cygwin|mingw|win32/ =~ RUBY_PLATFORM
      require_driver 'win32' 
    elsif /java/ =~ RUBY_PLATFORM
      require_driver 'jruby' 
    else
      require_driver 'posix' 
    end
  end
end