Hi,

2010/9/9 Nikolai Weibull <now / bitwi.se>:
> On Thu, Sep 9, 2010 at 07:00, Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
>> Hi,
>>
>> In message "Re: [ruby-core:32200] Ruby 2.0 Wish-list?"
>>    on Thu, 9 Sep 2010 11:49:06 +0900, Rocky Bernstein <rockyb / rubyforge.org> writes:
>>
>> |Any plans for error messages in languages other than English?
>>
>> For application internationalization, you can use gettext, etc.
>> But for Ruby itself, we have no plan, because:
>>
>>  * for most of Ruby code use English words, so that we can expect
>>    programmers to recognize English messages.
>>  * allowing message switch make the interpreter more complex, and
>>    bloat.
>
>  * Localized error messages are a lot more difficult to Google

 * it requires translation whenever new exception is introduced,
   which may block release management.

 * you can do it yourself if you really need it :-)


$ cat japanese-error-message.rb
# coding: UTF-8

at_exit do
  trace = $!.backtrace
  msg = $!.to_s
  msg = case msg
  when /\Aundefined local variable or method `(.*?)' for (.*?)\z/
    "#$2 には #$1 というローカル変数もメソッドも定義されていません"
  # ...
  else
    msg
  end
  puts "#{ trace.shift }: #{ msg } (#{ $!.class })"
  trace.each {|t| puts "        from " + t }
  exit!
end


$ ./ruby -r./japanese-error-message -e 'def foo; bar; end; foo'
-e:1:in `foo': main:Object には bar というローカル変数もメソッドも定義されていません (NameError)
        from -e:1:in `<main>'

-- 
Yusuke Endoh <mame / tsg.ne.jp>