Skip to content

Commit

Permalink
workaround to work with i18n-0.4.x and don't throw the whole trace wi…
Browse files Browse the repository at this point in the history
…th the deprecation warning. #6428
  • Loading branch information
thegcat committed Sep 17, 2010
1 parent bd193a0 commit ba15e4e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 12 additions & 0 deletions config/initializers/10-patches.rb
Expand Up @@ -78,3 +78,15 @@ module AsynchronousMailer
end

ActionMailer::Base.send :include, AsynchronousMailer

module I18n
module Backend
module Base
def warn_syntax_deprecation!
return if @skip_syntax_deprecation
warn "The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead.\nDowngrade your i18n gem to 0.3.7 (everything above must be deinstalled) to remove this warning, see http://www.redmine.org/issues/5608 for more information."
@skip_syntax_deprecation = true
end
end
end
end
4 changes: 2 additions & 2 deletions lib/redmine/i18n.rb
Expand Up @@ -37,15 +37,15 @@ def ll(lang, str, value=nil)

def format_date(date)
return nil unless date
Setting.date_format.blank? ? ::I18n.l(date.to_date) : date.strftime(Setting.date_format)
Setting.date_format.blank? ? ::I18n.l(date.to_date, :count => date.strftime('%d')) : date.strftime(Setting.date_format)
end

def format_time(time, include_date = true)
return nil unless time
time = time.to_time if time.is_a?(String)
zone = User.current.time_zone
local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time)
Setting.time_format.blank? ? ::I18n.l(local, :format => (include_date ? :default : :time)) :
Setting.time_format.blank? ? ::I18n.l(local, :count => local.strftime('%d'), :format => (include_date ? :default : :time)) :
((include_date ? "#{format_date(time)} " : "") + "#{local.strftime(Setting.time_format)}")
end

Expand Down
8 changes: 4 additions & 4 deletions test/unit/lib/redmine/i18n_test.rb
Expand Up @@ -29,7 +29,7 @@ def test_date_format_default
set_language_if_valid 'en'
today = Date.today
Setting.date_format = ''
assert_equal I18n.l(today), format_date(today)
assert_equal I18n.l(today, :count => today.strftime('%d')), format_date(today)
end

def test_date_format
Expand All @@ -47,7 +47,7 @@ def test_date_and_time_for_each_language
format_date(Date.today)
format_time(Time.now)
format_time(Time.now, false)
assert_not_equal 'default', ::I18n.l(Date.today, :format => :default), "date.formats.default missing in #{lang}"
assert_not_equal 'default', ::I18n.l(Date.today, :count => Date.today.strftime('%d'), :format => :default), "date.formats.default missing in #{lang}"
assert_not_equal 'time', ::I18n.l(Time.now, :format => :time), "time.formats.time missing in #{lang}"
end
assert l('date.day_names').is_a?(Array)
Expand All @@ -63,8 +63,8 @@ def test_time_format_default
now = Time.now
Setting.date_format = ''
Setting.time_format = ''
assert_equal I18n.l(now), format_time(now)
assert_equal I18n.l(now, :format => :time), format_time(now, false)
assert_equal I18n.l(now, :count => now.strftime('%d')), format_time(now)
assert_equal I18n.l(now, :count => now.strftime('%d'), :format => :time), format_time(now, false)
end

def test_time_format
Expand Down

0 comments on commit ba15e4e

Please sign in to comment.