Hello,

Currently, the .inspect method of ActiveSupport::Duration handles the 
i18n-ization like this:

    def inspect #:nodoc:
      parts.
        reduce(::Hash.new(0)) { |h,(l,r)| h[l] += r; h }.
        sort_by {|unit,  _ | [:years, :months, :days, :minutes, 
:seconds].index(unit)}.
        map     {|unit, val| "#{val} #{val == 1 ? unit.to_s.chop : unit.to_s}"}.
        to_sentence(locale: ::I18n.default_locale)
    end



Which can be frustrating if the user's current locale is different from the 
default one.

In my case, a french user would read english versions of inspected 
durations instead of french ones (ie: "12 hours" instead of "12 heures")

What I propose is to change this line of code:

to_sentence(locale: ::I18n.default_locale)


To this:

to_sentence(locale: ::I18n.locale)


Regards,
Samy

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to