I added a ticket over here: http://rails.lighthouseapp.com/projects/8994/tickets/2010-arrayto_sentence-raises-with-missing-translations
I have been working with an I18n'ed Rails project for over six months now. I had grabbed the original I18n module from git and patched some of the usage of I18n in rails 2.1.0.
I just recently upgraded to Rails 2.2.2 and am very happy with the changes to I18n, especially the human_attribute_name and Errors#generate_message methodology. Better than what I had -- and now I am going to try to integrate with these new features.
Everything is working great but Array#to_sentence causes weird issues withing application boot-up and logging. The to_sentence method is used often for displaying errors and logging ( ie Duration#inspect ). And I wouldn't expect it to be I18n'ed in these cases. I overrode the I18n exception handler to raise in certain cases, and Array#to_sentence seems to be truly exceptional and was bringing the application down after attempting to log a memcache miss. ( I have since worked around this )
I added a patch to the ticket above to not lookup with I18n if defaults are passed into the to_sentence method. It also adds String defaults to the I18n.translate calls so it will not raise ( if the default I18n exception handler is not used ) or use weird "translation missing:" messages. I also passed in the defaults to all logging and error message usage of to_sentence. I don't think anyone is planning on I18n'ing the errors and logging, right?
<pre> irb(main):002:0> require 'activesupport.rb' => true irb(main):003:0> [1,2,3].to_sentence => "1, 2, and 3" irb(main):004:0> [1,2,3].to_sentence :locale => :de => "1translation missing: de, support, array, words_connector2translation missing: de, support, array, last_word_connector3" </pre>
I also have added some features to I18n that allow more "Rails-like" overriding of the exception handler, could be as simple as "config.i18n :exception_handler => proc{ ... }" in the environment files.
And a forthcoming commit with failover locales "I18n.locale = [:'en- us', :en]"
Thanks. Andrew