Rails 2.2のi18nライブラリ、i18n_generators を試す

参考

楽天テクノロジーカンファレンス2008でLTしてきました


プラグインとして入れた
# ./script/plugin install git://github.com/amatsuda/i18n_generators.git
日本語化するときにエラった
# ./script/generate i18n ja
      exists  config/locales
   identical  config/locales/ja.yml
undefined method `count' for #<Array:0x24f3e0c>

どうもArray#countは1.9(1.8.7)のメソッドらしい・・?自分の環境は1.8.6です。
しょうがないので1.8.7を入れてやりなおし。

# ruby script/generate i18n ja
      exists  config/locales
   identical  config/locales/ja.yml
       debug  took 1.154772 secs to translate 3 models.
       debug  took 1.095984 secs to translate 9 words.
      create  config/locales/translation_ja.yml

そのあと1.8.7でサーバーを起動しようとしたらまたエラッた。

# ruby script/server 
[BUG] cross-thread violation on rb_gc()
ruby 1.8.6 (2008-03-03) [universal-darwin9.0]

zsh: abort (core dumped)  ruby script/server

うげえ・・エラーメッセージに1.8.6と出てるけど1.8.7起動です。どこですり替わっているのか・・
でも1.8.6でサーバー起動したら動いたので放置。

結局、日本語化はうまくいきました

config/locales/ja.ymlのactiverecord:errors周りは一塊で書かないとmissingになってしまうようだ。ビューの'Edit'とかのリンク部分は日本語化ができなかった。
ざくっとテンプレ的なロケールファイルをつくってくれる/翻訳をやってくれるのは便利だ。