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.

This project is archived and is in readonly mode.

Array#to_sentence raises with missing translations

#2010

The Array#to_sentence raises errors if a locale other than :en is used and is missing the default values. ( Think custom I18n.backend that is user editable ).

Also, anywhere that uses to_sentence for errors and logging probably shouldn't be localized.

Duration.inspect was also making weird use of to_sentence ( ie, "5 minutes und 30 seconds" for a I18n.locale of :de" ).

Added a patch that will only lookup the defaults if not passed in. Stores defaults in an Array constant. Patches any internal use of to_sentence to always pass in the defaults hash. Test for ensuring that defaults are not looked-up when defaults are passed in.

This will need to be merged with Ticket #1847 to_sentence breaks api if accepted.

Reported by abriening · February 18th, 2009 @ 08:37 PM

State: resolved
Milestone: 2.x
Assigned to: Sven Fuchs Sven Fuchs
Importance: none

Activity

  1. DHH
    DHH
    • Assigned user set to Sven Fuchs

    February 22nd, 2009 @ 03:18 PM

  2. abriening
    abriening

    Just wanted to clarify, this does not raise with the I8n.default_exception_handler but makes ugly logs and error messages.

    
    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"
    

    This was raising with my overridden exception_handler didn't realize this till after I posted this ticket.

    Either way Rails' internal errors and logging shouldn't be localized.

    February 22nd, 2009 @ 05:58 PM

  3. abriening
    abriening
    • Tag changed from activesupport, array, duration, i18n, to_sentence to activesupport, array, duration, i18n, patch, to_sentence

    Adding a new patch.

    Includes changes from commit ff1afb, #1847 to_sentence breaks api.

    Note this patch assumes that you are either using the old :connector and :skip_last_comma options or the new options but not both.

    I also followed the guidelines this time :)

    February 22nd, 2009 @ 06:35 PM

  4. Repository
    Repository
    • State changed from new to resolved

    (from [6de83562f91028629bd24447aa521bc72ef8277a]) Force all internal calls to Array#to_sentence to use English [#2010 Array#to_sentence raises with missing translations state:resolved] http://github.com/rails/rails/co...

    February 27th, 2009 @ 01:23 PM