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.
Gets the CGI object. If it is nil, returns new CGI object.
# File lib/locale/cgi.rb, line 100 100: def cgi 101: @@locale_system_module.cgi 102: end
Sets a CGI object.
# File lib/locale/cgi.rb, line 93 93: def cgi=(cgi_) 94: set_cgi(cgi_) 95: cgi_ 96: end
Clear default/current locale.
# File lib/locale.rb, line 172 172: def clear 173: set(nil) 174: set_current(nil) 175: self 176: end
Gets the current locale (Locale::Object).
If the current locale is not set, this returns default locale.
# 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.
Locale.current = "ja_JP.eucJP" Locale.current = Locale::Object.new("ja", "JP", "eucJP")
# File lib/locale.rb, line 111 111: def current=(lang) 112: set_current(lang) 113: @@current 114: end
Same as Locale.set_default.
# 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.
# 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.
# 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.
# 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.
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"))
# 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)).
# 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.
# File lib/locale.rb, line 56 56: def system 57: @@locale_system_module.system 58: end