#15 new
Randy

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

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

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

Comments and changes to this ticket

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The second incarnation of Globalize for Rails, which will let your Rails app speak any language on Earth, and beyond.

People watching this ticket

Attachments

Pages