Module Locale
In: lib/locale/base.rb
lib/locale/object.rb
lib/locale/jruby.rb
lib/locale/posix.rb
lib/locale/win32_table.rb
lib/locale/win32.rb
lib/locale/cgi.rb
lib/locale.rb

Locale module manages the locale informations of the application.

Methods

cgi   cgi=   charset   clear   codeset   current   current=   current_charset   default   default=   get   set   set_cgi   set_current   set_default   system   system_module  

Classes and Modules

Module Locale::SystemBase
Module Locale::SystemCGI
Module Locale::SystemJRuby
Module Locale::SystemPosix
Module Locale::SystemWin32
Class Locale::Object

Public Instance methods

Gets the CGI object. If it is nil, returns new CGI object.

  • Returns: the CGI object

[Source]

     # File lib/locale/cgi.rb, line 100
100:   def cgi
101:     @@locale_system_module.cgi
102:   end

Sets a CGI object.

  • cgi_: CGI object
  • Returns: cgi_

[Source]

    # File lib/locale/cgi.rb, line 93
93:   def cgi=(cgi_)
94:     set_cgi(cgi_)
95:     cgi_
96:   end

Gets the charset of the current locale.

[Source]

     # File lib/locale.rb, line 161
161:   def charset
162:     codeset
163:   end

Clear default/current locale.

  • Returns: self

[Source]

     # File lib/locale.rb, line 172
172:   def clear
173:     set(nil)
174:     set_current(nil)
175:     self
176:   end

Same as charset. Gets the charset of the current locale.

[Source]

     # File lib/locale.rb, line 155
155:   def codeset
156:     current.charset
157:   end

Gets the current locale (Locale::Object).

If the current locale is not set, this returns default locale.

[Source]

    # File lib/locale.rb, line 72
72:   def current
73:     @@current = default unless @@current
74:     @@current
75:   end

Sets a current locale. This is a single argument version of Locale.set_current.

[Source]

     # File lib/locale.rb, line 111
111:   def current=(lang)
112:     set_current(lang)
113:     @@current
114:   end

Same as codeset. Returns the charset of the current locale.

[Source]

     # File lib/locale.rb, line 166
166:   def current_charset
167:     codeset
168:   end

Gets the default locale.

If the default locale not set, this returns system locale.

[Source]

    # File lib/locale.rb, line 64
64:   def default
65:     @@default ? @@default : system
66:   end

Same as Locale.set_default.

[Source]

    # File lib/locale.rb, line 49
49:   def default=(locale)
50:     set_default(locale)
51:     @@default
52:   end

Notice: lctype is deprecated. Use this with no parameter instead.

[Source]

     # File lib/locale.rb, line 148
148:   def get
149:     @@current = default unless @@current
150:     @@current
151:   end

Sets a default locale. This function is an alias of Locale.set_default with calling set_current(nil).

Notice: Locale.set(lctype, locale) is deprecated.

[Source]

     # File lib/locale.rb, line 129
129:   def set(lang, country = nil, charset = nil)
130:     set_current(nil)
131:     if lang.kind_of? String
132:       set_default(Locale::Object.new(lang, country, charset))
133:     elsif lang.kind_of? Locale::Object
134:       set_default(lang)
135:     else
136:       set_default(nil)
137:     end
138:     @@default
139:   end

Sets a CGI object.

  • cgi_: CGI object
  • Returns: self

[Source]

    # File lib/locale/cgi.rb, line 85
85:   def set_cgi(cgi_)
86:     @@locale_system_module.set_cgi(cgi_)
87:     self
88:   end

Sets a locale as the current locale.

This returns the current Locale::Object.

  • lang: Locale::Object or locale name(String), or language name.
  • country: the country code(String)
  • charset: the charset(override the charset even if the locale name has charset).
  • Returns: self
     Locale.set_current("ja_JP.eucJP")
     Locale.set_current("ja", "JP")
     Locale.set_current("ja", "JP", "eucJP")
     Locale.set_current("ja", nil, "eucJP")
     Locale.set_current(Locale::Object.new("ja", "JP", "eucJP"))
    

[Source]

     # File lib/locale.rb, line 90
 90:   def set_current(lang, country = nil, charset = nil)
 91:     if lang == nil
 92:       @@current = nil
 93:     else
 94:       if lang.kind_of? Locale::Object
 95:         @@current = lang
 96:       else
 97:         @@current = Locale::Object.new(lang, country, charset)
 98:       end
 99:       @@current.charset ||= @@locale_system_module.charset
100:     end
101:     self
102:   end

Sets the default locale (Locale::Object or String(such as ja_JP.eucJP)).

  • locale: the default locale
  • Returns: self.

[Source]

    # File lib/locale.rb, line 32
32:   def set_default(locale)
33:     if locale
34:       if locale.kind_of? Locale::Object
35:         @@default = locale
36:       else
37:         @@default = Locale::Object.new(locale)
38:       end
39:       @@default.charset ||= @@locale_system_module.charset
40:     else
41:       @@default = nil
42:     end
43:     self
44:   end

Gets the system locale.

[Source]

    # File lib/locale.rb, line 56
56:   def system
57:     @@locale_system_module.system
58:   end

Gets the current system module. This is used for debugging.

[Source]

     # File lib/locale.rb, line 180
180:   def system_module
181:     @@locale_system_module
182:   end

[Validate]