| Class | IRB::Locale |
| In: |
irb/locale.rb
|
| Parent: | Object |
Constants
| JPDefaultLocale | = | "ja" |
| LOCALE_DIR | = | "/lc/" |
External Aliases
| load | -> | toplevel_load |
Attributes
| lang | [R] |
Public Class methods
# File irb/locale.rb, line 22
22: def initialize(locale = nil)
23: @lang = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
24: end
Public Instance methods
# File irb/locale.rb, line 40
40: def String(mes)
41: mes = super(mes)
42: case @lang
43: when /^ja/
44: mes = Kconv::kconv(mes, lc2kconv(@lang))
45: else
46: mes
47: end
48: mes
49: end
# File irb/locale.rb, line 139
139: def find(file , paths = $:)
140: dir = File.dirname(file)
141: dir = "" if dir == "."
142: base = File.basename(file)
143: if dir[0] == ?/ #/
144: return lc_path = search_file(dir, base)
145: else
146: for path in $:
147: if lc_path = search_file(path + "/" + dir, base)
148: return lc_path
149: end
150: end
151: end
152: nil
153: end
# File irb/locale.rb, line 105
105: def load(file, priv=nil)
106: dir = File.dirname(file)
107: dir = "" if dir == "."
108: base = File.basename(file)
109:
110: if /^ja(_JP)?$/ =~ @lang
111: back, @lang = @lang, "C"
112: end
113: begin
114: if dir[0] == ?/ #/
115: lc_path = search_file(dir, base)
116: return real_load(lc_path, priv) if lc_path
117: end
118:
119: for path in $:
120: lc_path = search_file(path + "/" + dir, base)
121: return real_load(lc_path, priv) if lc_path
122: end
123: ensure
124: @lang = back if back
125: end
126: raise LoadError, "No such file to load -- #{file}"
127: end
# File irb/locale.rb, line 63
63: def print(*opts)
64: ary = opts.collect{|opt| String(opt)}
65: super(*ary)
66: end
# File irb/locale.rb, line 73
73: def puts(*opts)
74: ary = opts.collect{|opt| String(opts)}
75: super(*ary)
76: end
# File irb/locale.rb, line 78
78: def require(file, priv = nil)
79: rex = Regexp.new("lc/#{Regexp.quote(file)}\.(so|o|sl|rb)?")
80: return false if $".find{|f| f =~ rex}
81:
82: case file
83: when /\.rb$/
84: begin
85: load(file, priv)
86: $".push file
87: return true
88: rescue LoadError
89: end
90: when /\.(so|o|sl)$/
91: return super
92: end
93:
94: begin
95: load(f = file + ".rb")
96: $".push f #"
97: return true
98: rescue LoadError
99: return ruby_require(file)
100: end
101: end