Manually require i18n 0.4.2 before Rails tries to load the most recent gem (#7013).
This workaround makes Redmine work even if i18n 0.5.0 gem is installed. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4516 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
9f18426ca7
commit
3c1576e364
|
@ -106,5 +106,17 @@ module Rails
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: Workaround for #7013 to be removed for 1.2.0
|
||||||
|
# Loads i18n 0.4.2 before Rails loads any more recent gem
|
||||||
|
# 0.5.0 is not compatible with the old interpolation syntax
|
||||||
|
# Plugins will have to migrate to the new syntax for 1.2.0
|
||||||
|
require 'rubygems'
|
||||||
|
begin
|
||||||
|
gem 'i18n', '0.4.2'
|
||||||
|
rescue Gem::LoadError => load_error
|
||||||
|
$stderr.puts %(Missing the i18n 0.4.2 gem. Please `gem install -v=0.4.2 i18n`)
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
# All that for this:
|
# All that for this:
|
||||||
Rails.boot!
|
Rails.boot!
|
||||||
|
|
|
@ -86,7 +86,7 @@ module I18n
|
||||||
module Base
|
module Base
|
||||||
def warn_syntax_deprecation!(*args)
|
def warn_syntax_deprecation!(*args)
|
||||||
return if @skip_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."
|
warn "The {{key}} interpolation syntax in I18n messages is deprecated and will be removed in Redmine 1.2. Please use %{key} instead, see http://www.redmine.org/issues/7013 for more information."
|
||||||
@skip_syntax_deprecation = true
|
@skip_syntax_deprecation = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,7 +37,7 @@ module Redmine
|
||||||
|
|
||||||
def format_date(date)
|
def format_date(date)
|
||||||
return nil unless date
|
return nil unless date
|
||||||
Setting.date_format.blank? ? ::I18n.l(date.to_date, :count => date.strftime('%d')) : date.strftime(Setting.date_format)
|
Setting.date_format.blank? ? ::I18n.l(date.to_date) : date.strftime(Setting.date_format)
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_time(time, include_date = true)
|
def format_time(time, include_date = true)
|
||||||
|
@ -45,7 +45,7 @@ module Redmine
|
||||||
time = time.to_time if time.is_a?(String)
|
time = time.to_time if time.is_a?(String)
|
||||||
zone = User.current.time_zone
|
zone = User.current.time_zone
|
||||||
local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time)
|
local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time)
|
||||||
Setting.time_format.blank? ? ::I18n.l(local, :count => local.strftime('%d'), :format => (include_date ? :default : :time)) :
|
Setting.time_format.blank? ? ::I18n.l(local, :format => (include_date ? :default : :time)) :
|
||||||
((include_date ? "#{format_date(time)} " : "") + "#{local.strftime(Setting.time_format)}")
|
((include_date ? "#{format_date(time)} " : "") + "#{local.strftime(Setting.time_format)}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Redmine::I18nTest < ActiveSupport::TestCase
|
||||||
set_language_if_valid 'en'
|
set_language_if_valid 'en'
|
||||||
today = Date.today
|
today = Date.today
|
||||||
Setting.date_format = ''
|
Setting.date_format = ''
|
||||||
assert_equal I18n.l(today, :count => today.strftime('%d')), format_date(today)
|
assert_equal I18n.l(today), format_date(today)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_format
|
def test_date_format
|
||||||
|
@ -47,7 +47,7 @@ class Redmine::I18nTest < ActiveSupport::TestCase
|
||||||
format_date(Date.today)
|
format_date(Date.today)
|
||||||
format_time(Time.now)
|
format_time(Time.now)
|
||||||
format_time(Time.now, false)
|
format_time(Time.now, false)
|
||||||
assert_not_equal 'default', ::I18n.l(Date.today, :count => Date.today.strftime('%d'), :format => :default), "date.formats.default missing in #{lang}"
|
assert_not_equal 'default', ::I18n.l(Date.today, :format => :default), "date.formats.default missing in #{lang}"
|
||||||
assert_not_equal 'time', ::I18n.l(Time.now, :format => :time), "time.formats.time missing in #{lang}"
|
assert_not_equal 'time', ::I18n.l(Time.now, :format => :time), "time.formats.time missing in #{lang}"
|
||||||
end
|
end
|
||||||
assert l('date.day_names').is_a?(Array)
|
assert l('date.day_names').is_a?(Array)
|
||||||
|
@ -63,8 +63,8 @@ class Redmine::I18nTest < ActiveSupport::TestCase
|
||||||
now = Time.now
|
now = Time.now
|
||||||
Setting.date_format = ''
|
Setting.date_format = ''
|
||||||
Setting.time_format = ''
|
Setting.time_format = ''
|
||||||
assert_equal I18n.l(now, :count => now.strftime('%d')), format_time(now)
|
assert_equal I18n.l(now), format_time(now)
|
||||||
assert_equal I18n.l(now, :count => now.strftime('%d'), :format => :time), format_time(now, false)
|
assert_equal I18n.l(now, :format => :time), format_time(now, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_time_format
|
def test_time_format
|
||||||
|
|
Loading…
Reference in New Issue