diff options
author | Dominik Masur <dominik.masur@gmail.com> | 2015-01-12 19:34:32 +0100 |
---|---|---|
committer | Dominik Masur <dominik.masur@gmail.com> | 2015-01-12 19:34:32 +0100 |
commit | f76d1aa54d25670f6b6d635ad0350cea8b88c706 (patch) | |
tree | 0ac43168ff44ff80f5e4665529647f3069901339 /activesupport/lib | |
parent | 970fe27b02fa7df9e01276861adebc131083958c (diff) | |
download | rails-f76d1aa54d25670f6b6d635ad0350cea8b88c706.tar.gz rails-f76d1aa54d25670f6b6d635ad0350cea8b88c706.tar.bz2 rails-f76d1aa54d25670f6b6d635ad0350cea8b88c706.zip |
Removing :en in favor of I18n.default_locale in duration#inspect
Hi there,
i have an app without english as available locale. So i got an error when we try to inspect something like 1.day. This is done automatically when we use the dalli cache.
I would like to change the :en to ::I18n.default_locale to be sure that this is always constant and is an available locale.
Tests are all green with this change.
Calculating -------------------------------------
:locale => :en 2.024k i/100ms
:locale => ::I18n.default_locale 2.236k i/100ms
-------------------------------------------------
:locale => :en 25.758k (±26.3%) i/s - 117.392k
:locale => ::I18n.default_locale 26.311k (±18.1%) i/s - 127.452k
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/duration.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index 2818b8d68b..5a64fc52cc 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -91,7 +91,7 @@ module ActiveSupport 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 => :en) + to_sentence(locale: ::I18n.default_locale) end def as_json(options = nil) #:nodoc: |