Do you know rubyists in Japan use Irb in Japanese?
% irb --help Usage: irb.rb [options] [programfile] [arguments] -f ~/.irbrc を読み込まない. -m bcモード(分数, 行列の計算ができる) -d $DEBUG をtrueにする(ruby -d と同じ) -r load-module ruby -r と同じ.
Irb has had ability to localize the help message and some error messages, and has been shipped with Japanese localization by historical reason. Also I improved this localization mechanism so that messages are converted correctly with
String#encode and that Irb can load a localization from a gem.
But this fact is not well known. I could not find any other localization with Google search.
Recently Abinoam Jr. wrote Portugese localization for IRB. He sent it to me and I suggested that he should distribute it as a gem.
At this time I found that the mechanism that load a localization from a gem is broken on Ruby 1.9.2. Anyway, I fixed the problem at r30448 and the next patchlevel release of Ruby 1.9.2 will be able to load a localization from a gem again.
It is quite easy. Suppose that we are writing a localization for zh_JP.UTF-8@ancient locale and let /path/to/somewhere the working directory.
- Copy error.rb and help-message from $(rubylibdir)/irb/lc into /path/to/somewhere/irb/lc/zh_JP.UTF-8@ancient/. *1
Translate the copies of error.rb and help-message into zh_JP.UTF-8 like this:
# -*- coding: UTF-8 -*- 律: irb [選項] [簒譜] [参數] -f 不讀~/.irbrc -m bc態(得簒分數行列) ....
Place the correct magic comments in both of the files.
- Move the irb directory which contains the translated files into somewhere under
$LOAD_PATH. I think $(sitelibdir)/ is preferred.
- You can distribute the irb/lc/<your-locale>/* as a gem instead of install it as a legacy style library. Ruby 1.9.1 and the next release of Ruby 1.9.2 can load a localization from a gem.
*1 Japanese localization has encoding_aliases.rb in addition to the two files. But encoding_aliases.rb is just for backward compatibility with Ruby 1.8. You don't have to implement it in your locale