From: Yusuke ENDOH Date: 2010-09-09T23:00:38+09:00 Subject: [ruby-core:32232] Re: Ruby 2.0 Wish-list? Hi, 2010/9/9 Nikolai Weibull : > On Thu, Sep 9, 2010 at 07:00, Yukihiro Matsumoto wrote: >> Hi, >> >> In message "Re: [ruby-core:32200] Ruby 2.0 Wish-list?" >> on Thu, 9 Sep 2010 11:49:06 +0900, Rocky Bernstein 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 `
' -- Yusuke Endoh