Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

handle non-string values in the "en.yml" files

#15

In summary, the problem is that some "translated values" in the built-in Rails en.yml files have non-string values such as booleans, . For example in activesupport/lib/active_support/locale/en.yml:

en:
<---- snip ---->

Used in array.to_sentence.

support: array:

 sentence_connector: "and"
 skip_last_comma: false

When globalize2 gets the "translation" for :"support.array.skip_last_comma", which is false, it assumes there is no translation (but there is... it's just the boolean value of false). This problem goes unnoticed until you extend the I18n.exception_handler (to do more fallback logic, exception notification, etc) like so:

module I18n
def self.just_raise_that_exception(exception, locale, key, options)

if MissingTranslationData === exception
  # fallbacks, exception notification, etc
  raise exception
end

end end

I18n.exception_handler = :just_raise_that_exception

To reproduce this problem, just extend the I18n module as above, then go into the console and create an invalid object then look at its error messages in sentence form:

o = SomeObjectThatHasValidations.new
o.valid?
c.errors.full_messages.to_sentence
I18n::MissingTranslationData: translation missing: en, support, array, skip_last_comma

Reported by Randy · August 17th, 2009 @ 04:38 PM

State: new
Milestone: none
Assigned to: Josh H Josh H

Activity

  1. Randy
    Randy

    Sorry about the formatting... just copied it from an email. The patch should be self-explanatory.

    I'll add some tests and append to this ticket.

    August 17th, 2009 @ 04:40 PM

  2. Randy
    Randy

    Here is the new patch, with changes to the test that takes this issue into account.

    August 18th, 2009 @ 05:46 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.