##// END OF EJS Templates
Manually require i18n 0.4.2 before Rails tries to load the most recent gem (#7013)....
Jean-Philippe Lang -
r4402:3c1576e364c9
parent child
Show More
@@ -106,5 +106,17 module Rails
106 end
106 end
107 end
107 end
108
108
109 # TODO: Workaround for #7013 to be removed for 1.2.0
110 # Loads i18n 0.4.2 before Rails loads any more recent gem
111 # 0.5.0 is not compatible with the old interpolation syntax
112 # Plugins will have to migrate to the new syntax for 1.2.0
113 require 'rubygems'
114 begin
115 gem 'i18n', '0.4.2'
116 rescue Gem::LoadError => load_error
117 $stderr.puts %(Missing the i18n 0.4.2 gem. Please `gem install -v=0.4.2 i18n`)
118 exit 1
119 end
120
109 # All that for this:
121 # All that for this:
110 Rails.boot!
122 Rails.boot!
@@ -86,7 +86,7 module I18n
86 module Base
86 module Base
87 def warn_syntax_deprecation!(*args)
87 def warn_syntax_deprecation!(*args)
88 return if @skip_syntax_deprecation
88 return if @skip_syntax_deprecation
89 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."
89 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."
90 @skip_syntax_deprecation = true
90 @skip_syntax_deprecation = true
91 end
91 end
92 end
92 end
@@ -37,7 +37,7 module Redmine
37
37
38 def format_date(date)
38 def format_date(date)
39 return nil unless date
39 return nil unless date
40 Setting.date_format.blank? ? ::I18n.l(date.to_date, :count => date.strftime('%d')) : date.strftime(Setting.date_format)
40 Setting.date_format.blank? ? ::I18n.l(date.to_date) : date.strftime(Setting.date_format)
41 end
41 end
42
42
43 def format_time(time, include_date = true)
43 def format_time(time, include_date = true)
@@ -45,7 +45,7 module Redmine
45 time = time.to_time if time.is_a?(String)
45 time = time.to_time if time.is_a?(String)
46 zone = User.current.time_zone
46 zone = User.current.time_zone
47 local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time)
47 local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time)
48 Setting.time_format.blank? ? ::I18n.l(local, :count => local.strftime('%d'), :format => (include_date ? :default : :time)) :
48 Setting.time_format.blank? ? ::I18n.l(local, :format => (include_date ? :default : :time)) :
49 ((include_date ? "#{format_date(time)} " : "") + "#{local.strftime(Setting.time_format)}")
49 ((include_date ? "#{format_date(time)} " : "") + "#{local.strftime(Setting.time_format)}")
50 end
50 end
51
51
@@ -29,7 +29,7 class Redmine::I18nTest < ActiveSupport::TestCase
29 set_language_if_valid 'en'
29 set_language_if_valid 'en'
30 today = Date.today
30 today = Date.today
31 Setting.date_format = ''
31 Setting.date_format = ''
32 assert_equal I18n.l(today, :count => today.strftime('%d')), format_date(today)
32 assert_equal I18n.l(today), format_date(today)
33 end
33 end
34
34
35 def test_date_format
35 def test_date_format
@@ -47,7 +47,7 class Redmine::I18nTest < ActiveSupport::TestCase
47 format_date(Date.today)
47 format_date(Date.today)
48 format_time(Time.now)
48 format_time(Time.now)
49 format_time(Time.now, false)
49 format_time(Time.now, false)
50 assert_not_equal 'default', ::I18n.l(Date.today, :count => Date.today.strftime('%d'), :format => :default), "date.formats.default missing in #{lang}"
50 assert_not_equal 'default', ::I18n.l(Date.today, :format => :default), "date.formats.default missing in #{lang}"
51 assert_not_equal 'time', ::I18n.l(Time.now, :format => :time), "time.formats.time missing in #{lang}"
51 assert_not_equal 'time', ::I18n.l(Time.now, :format => :time), "time.formats.time missing in #{lang}"
52 end
52 end
53 assert l('date.day_names').is_a?(Array)
53 assert l('date.day_names').is_a?(Array)
@@ -63,8 +63,8 class Redmine::I18nTest < ActiveSupport::TestCase
63 now = Time.now
63 now = Time.now
64 Setting.date_format = ''
64 Setting.date_format = ''
65 Setting.time_format = ''
65 Setting.time_format = ''
66 assert_equal I18n.l(now, :count => now.strftime('%d')), format_time(now)
66 assert_equal I18n.l(now), format_time(now)
67 assert_equal I18n.l(now, :count => now.strftime('%d'), :format => :time), format_time(now, false)
67 assert_equal I18n.l(now, :format => :time), format_time(now, false)
68 end
68 end
69
69
70 def test_time_format
70 def test_time_format
General Comments 0
You need to be logged in to leave comments. Login now