@@ -106,5 +106,17 module Rails | |||
|
106 | 106 | end |
|
107 | 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 | 121 | # All that for this: |
|
110 | 122 | Rails.boot! |
@@ -86,7 +86,7 module I18n | |||
|
86 | 86 | module Base |
|
87 | 87 | def warn_syntax_deprecation!(*args) |
|
88 | 88 | return if @skip_syntax_deprecation |
|
89 |
warn "The {{key}} interpolation syntax in I18n messages is deprecated |
|
|
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 | 90 | @skip_syntax_deprecation = true |
|
91 | 91 | end |
|
92 | 92 | end |
@@ -37,7 +37,7 module Redmine | |||
|
37 | 37 | |
|
38 | 38 | def format_date(date) |
|
39 | 39 | return nil unless date |
|
40 |
Setting.date_format.blank? ? ::I18n.l(date.to_date |
|
|
40 | Setting.date_format.blank? ? ::I18n.l(date.to_date) : date.strftime(Setting.date_format) | |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | def format_time(time, include_date = true) |
@@ -45,7 +45,7 module Redmine | |||
|
45 | 45 | time = time.to_time if time.is_a?(String) |
|
46 | 46 | zone = User.current.time_zone |
|
47 | 47 | local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time) |
|
48 |
Setting.time_format.blank? ? ::I18n.l(local |
|
|
48 | Setting.time_format.blank? ? ::I18n.l(local, :format => (include_date ? :default : :time)) : | |
|
49 | 49 | ((include_date ? "#{format_date(time)} " : "") + "#{local.strftime(Setting.time_format)}") |
|
50 | 50 | end |
|
51 | 51 |
@@ -29,7 +29,7 class Redmine::I18nTest < ActiveSupport::TestCase | |||
|
29 | 29 | set_language_if_valid 'en' |
|
30 | 30 | today = Date.today |
|
31 | 31 | Setting.date_format = '' |
|
32 |
assert_equal I18n.l(today |
|
|
32 | assert_equal I18n.l(today), format_date(today) | |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | 35 | def test_date_format |
@@ -47,7 +47,7 class Redmine::I18nTest < ActiveSupport::TestCase | |||
|
47 | 47 | format_date(Date.today) |
|
48 | 48 | format_time(Time.now) |
|
49 | 49 | format_time(Time.now, false) |
|
50 |
assert_not_equal 'default', ::I18n.l(Date.today |
|
|
50 | assert_not_equal 'default', ::I18n.l(Date.today, :format => :default), "date.formats.default missing in #{lang}" | |
|
51 | 51 | assert_not_equal 'time', ::I18n.l(Time.now, :format => :time), "time.formats.time missing in #{lang}" |
|
52 | 52 | end |
|
53 | 53 | assert l('date.day_names').is_a?(Array) |
@@ -63,8 +63,8 class Redmine::I18nTest < ActiveSupport::TestCase | |||
|
63 | 63 | now = Time.now |
|
64 | 64 | Setting.date_format = '' |
|
65 | 65 | Setting.time_format = '' |
|
66 |
assert_equal I18n.l(now |
|
|
67 |
assert_equal I18n.l(now |
|
|
66 | assert_equal I18n.l(now), format_time(now) | |
|
67 | assert_equal I18n.l(now, :format => :time), format_time(now, false) | |
|
68 | 68 | end |
|
69 | 69 | |
|
70 | 70 | def test_time_format |
General Comments 0
You need to be logged in to leave comments.
Login now