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
Module Locale::SystemWin32Table
Class Locale::Object

### Public Instance methods

cgi()

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

cgi=(cgi_)

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

charset()

Gets the charset of the current locale.

- Returns: the charset of the current locale (String)

[Source]

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

clear()

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

codeset()

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

- Returns: the charset of the current locale (String)

[Source]

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

current()

Gets the current locale (Locale::Object).

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

- Returns: the current locale (Locale::Object).

[Source]

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

current=(lang)

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

- lang: the Locale::Object
- Returns: the current locale (Locale::Object).

       Locale.current = "ja_JP.eucJP"
       Locale.current = Locale::Object.new("ja", "JP", "eucJP")

[Source]

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

current_charset()

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

- Returns: the charset of the current locale (String)

[Source]

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

default()

Gets the default locale.

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

- Returns: the default locale (Locale::Object).

[Source]

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

default=(locale)

Same as Locale.set_default.

- locale: the default locale (Locale::Object).
- Returns: locale.

[Source]

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

current
get

- Returns: the current locale (Locale::Object).

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

set(lang)
set(lang, country = nil, charset = nil)

- lang: language as String, or Locale::Object
- country: country as String or nil
- charset: charset as String or nil
- Returns: a Locale::Object.

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

set_cgi(cgi_)

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

set_current(lang, country = nil, charset = nil)

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

set_default(locale)

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

system()

Gets the system locale.

- Returns: the system locale (Locale::Object).

[Source]

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

system_module()

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

- Returns: the system module.

[Source]

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

[Validate]