Module: Locale
- Defined in:
- lib/gettext/locale.rb,
lib/gettext/cgi.rb,
lib/gettext/locale_cgi.rb,
lib/gettext/locale_posix.rb,
lib/gettext/locale_win32.rb,
lib/gettext/locale_object.rb,
lib/gettext/locale_table_win32.rb,
ext/gettext/locale_system.c
Overview
locale_table_win32.rb - Locale table for win32
Copyright (C) 2002-2006 Masao Mutoh <[email protected]>
You may redistribute it and/or modify it under the same
license terms as Ruby.
$Id: locale_table_win32.rb,v 1.5 2006/06/11 15:36:20 mutoh Exp $
Defined Under Namespace
Modules: System, SystemCGI, SystemPosix, SystemWin32 Classes: Object
Constant Summary collapse
- CTYPE =
:nodoc:
Locale::System::CTYPE
- NUMERIC =
:nodoc:
Locale::System::NUMERIC
- TIME =
:nodoc:
Locale::System::TIME
- COLLATE =
:nodoc:
Locale::System::COLLATE
- MONETARY =
:nodoc:
Locale::System::MONETARY
- MESSAGES =
:nodoc:
Locale::System::MESSAGES
- ALL =
:nodoc:
Locale::System::ALL
- @@default =
nil
- @@current =
nil
- @@locale_system_module =
SystemWin32
Class Method Summary collapse
-
.cgi ⇒ Object
Gets the CGI object.
-
.cgi=(cgi_) ⇒ Object
Sets a CGI object.
-
.charset ⇒ Object
Gets the charset of the current locale.
-
.clear ⇒ Object
Clear default/current locale.
-
.codeset ⇒ Object
Same as charset.
-
.current ⇒ Object
Gets the current locale (Locale::Object).
-
.current=(lang) ⇒ Object
Sets a current locale.
-
.current_charset ⇒ Object
Same as codeset.
-
.default ⇒ Object
Gets the default locale.
-
.default=(locale) ⇒ Object
Same as Locale.set_default.
-
.get(lctype = nil) ⇒ Object
call-seq: current get get(lctype = nil) (Deprecated).
-
.set(lang, country = nil, charset = nil) ⇒ Object
call-seq: set(lang) set(lang, country = nil, charset = nil).
-
.set_cgi(cgi_) ⇒ Object
Sets a CGI object.
-
.set_current(lang, country = nil, charset = nil) ⇒ Object
Sets a locale as the current locale.
-
.set_default(locale) ⇒ Object
Sets the default locale (Locale::Object or String(such as ja_JP.eucjP)).
-
.setlocale(lctype, loc) ⇒ Object
Deprecated.
-
.system ⇒ Object
Gets the system locale.
-
.system_module ⇒ Object
Gets the current system module.
Instance Method Summary collapse
-
#default_locale ⇒ Object
Gets the default Locale::Object.
-
#default_locale=(locale) ⇒ Object
Sets a default locale.
-
#set_default_locale(locale) ⇒ Object
Sets a default locale.
Class Method Details
.cgi ⇒ Object
Gets the CGI object. If it is nil, returns new CGI object.
-
Returns: the CGI object
36 37 38 |
# File 'lib/gettext/cgi.rb', line 36 def cgi @@locale_system_module.cgi end |
.cgi=(cgi_) ⇒ Object
Sets a CGI object.
-
cgi_: CGI object
-
Returns: cgi_
29 30 31 32 |
# File 'lib/gettext/cgi.rb', line 29 def cgi=(cgi_) set_cgi(cgi_) cgi_ end |
.charset ⇒ Object
Gets the charset of the current locale.
-
Returns: the charset of the current locale (String)
208 209 210 |
# File 'lib/gettext/locale.rb', line 208 def charset codeset end |
.clear ⇒ Object
Clear default/current locale.
-
Returns: self
219 220 221 222 223 |
# File 'lib/gettext/locale.rb', line 219 def clear set(nil) set_current(nil) self end |
.codeset ⇒ Object
Same as charset. Gets the charset of the current locale.
-
Returns: the charset of the current locale (String)
202 203 204 |
# File 'lib/gettext/locale.rb', line 202 def codeset current.charset end |
.current ⇒ Object
Gets the current locale (Locale::Object).
If the current locale is not set, this returns default locale.
-
Returns: the current locale (Locale::Object).
103 104 105 106 |
# File 'lib/gettext/locale.rb', line 103 def current @@current = default unless @@current @@current end |
.current=(lang) ⇒ Object
142 143 144 145 |
# File 'lib/gettext/locale.rb', line 142 def current=(lang) set_current(lang) @@current end |
.current_charset ⇒ Object
Same as codeset. Returns the charset of the current locale.
-
Returns: the charset of the current locale (String)
213 214 215 |
# File 'lib/gettext/locale.rb', line 213 def current_charset codeset end |
.default ⇒ Object
Gets the default locale.
If the default locale not set, this returns system locale.
-
Returns: the default locale (Locale::Object).
95 96 97 |
# File 'lib/gettext/locale.rb', line 95 def default @@default ? @@default : system end |
.default=(locale) ⇒ Object
Same as Locale.set_default.
-
locale: the default locale (Locale::Object).
-
Returns: locale.
80 81 82 83 |
# File 'lib/gettext/locale.rb', line 80 def default=(locale) set_default(locale) @@default end |
.get(lctype = nil) ⇒ Object
call-seq:
current
get
get(lctype = nil) (Deprecated)
-
Returns: the current locale (Locale::Object).
Notice: lctype is deprecated. Use this with no parameter instead.
188 189 190 191 192 |
# File 'lib/gettext/locale.rb', line 188 def get(lctype = nil) warn "Locale.get(lctype) is deprecated. Use Locale.get (noparam) instead." if lctype @@current = default unless @@current @@current end |
.set(lang, country = nil, charset = nil) ⇒ Object
call-seq:
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.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/gettext/locale.rb', line 160 def set(lang, country = nil, charset = nil) if lang.kind_of? Numeric warn "Locale.set(lctype, locale) is deprecated. Use Locale.set(locale) instead." # Locale.set(Locale::CTYPE, "ja_JP.eucJP") "country" means locale. lang = country country = nil charset = nil end set_current(nil) if lang.kind_of? String set_default(Locale::Object.new(lang, country, charset)) elsif lang.kind_of? Locale::Object set_default(lang) else set_default(nil) end @@default end |
.set_cgi(cgi_) ⇒ Object
Sets a CGI object.
-
cgi_: CGI object
-
Returns: self
21 22 23 24 |
# File 'lib/gettext/cgi.rb', line 21 def set_cgi(cgi_) @@locale_system_module.set_cgi(cgi_) self end |
.set_current(lang, country = nil, charset = nil) ⇒ Object
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"))
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/gettext/locale.rb', line 121 def set_current(lang, country = nil, charset = nil) if lang == nil @@current = nil else if lang.kind_of? Locale::Object @@current = lang else @@current = Locale::Object.new(lang, country, charset) end @@current.charset ||= @@locale_system_module.get_charset(@@current) end self end |
.set_default(locale) ⇒ Object
Sets the default locale (Locale::Object or String(such as ja_JP.eucjP)).
-
locale: the default locale
-
Returns: self.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/gettext/locale.rb', line 63 def set_default(locale) if locale if locale.kind_of? Locale::Object @@default = locale else @@default = Locale::Object.new(locale) end @@default.charset ||= @@locale_system_module.get_charset(@@default) else @@default = nil end self end |
.setlocale(lctype, loc) ⇒ Object
Deprecated. Use Locale.set or Locale.set_current instead.
195 196 197 198 |
# File 'lib/gettext/locale.rb', line 195 def setlocale(lctype, loc) warn "Deprecated. Use Locale#set instead." set(lctype, loc) end |
.system ⇒ Object
Gets the system locale.
-
Returns: the system locale (Locale::Object).
87 88 89 |
# File 'lib/gettext/locale.rb', line 87 def system @@locale_system_module.system end |
.system_module ⇒ Object
Gets the current system module. This is used for debugging.
-
Returns: the system module.
227 228 229 |
# File 'lib/gettext/locale.rb', line 227 def system_module @@locale_system_module end |
Instance Method Details
#default_locale ⇒ Object
Gets the default Locale::Object.
-
Returns: the default locale
67 68 69 |
# File 'lib/gettext/locale_posix.rb', line 67 def default_locale @@default_locale end |
#default_locale=(locale) ⇒ Object
Sets a default locale. en.UTF-8 is the default value if not set.
-
locale: Locale::Object
-
Returns: locale
60 61 62 63 |
# File 'lib/gettext/locale_posix.rb', line 60 def default_locale=(locale) set_default_locale(locale) locale end |
#set_default_locale(locale) ⇒ Object
Sets a default locale. en.UTF-8 is the default value if not set.
-
locale: Locale::Object object. You can’t set nil.
-
Returns: self
51 52 53 54 55 |
# File 'lib/gettext/locale_posix.rb', line 51 def set_default_locale(locale) raise "Wrong parameter: #{locale}" if locale.nil? @@default_locale = locale self end |