Forum: Rails I18n I18n.t returns a empty hash when a translation is missing

Posted by Christophe P. (seyev)
on 2010-07-05 12:14
Hello,

I'm migrating from rails 2.2.2 to rails 2.3.8 and I have a strange issue
with I18n.translate.

In rails 2.2.2 development, when I try to get an untranslated key I have
a error like "Translation missing: [...]"

In rails 2.3.8 development, The I18n.t method returns an empty hash ({})
for the same missing translation.

In environment.rb, I have the following code that is related to the I18n
module:
config.after_initialize do
  # No fallback locales in development environment; we want to see those
  # translation missing errors.
  fallbacks = {}
  I18n.valid_locales.each do |l|
    fallbacks[l] = [l]
  end
  I18n.fallbacks = fallbacks

  # Additionally, we log missing keys
  require 'globalize/i18n/missing_translations_log_handler'
  I18n.missing_translations_logger = RAILS_DEFAULT_LOGGER
  I18n.exception_handler = :missing_translations_log_handler
end

I tried to comment it out but it the same empty hash was returned.

Also, the I18n.t :default option seems to be broken as well. I suspect
this is due to my stange behavior.

Any suggestion?

Thanks in advance,
Christophe
Posted by Christophe P. (seyev)
on 2010-07-05 12:26
Find out: it was the globalize2 plugin that caused this strange issue.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.