Skip to content

Commit f26380b

Browse files
author
Sven Fuchs
committed
switch to using I18n.load_translations instead of requiring plain ruby files
1 parent bfa143f commit f26380b

File tree

6 files changed

+131
-128
lines changed

6 files changed

+131
-128
lines changed

actionpack/lib/action_view.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
require 'action_view/template_error'
3636

3737
I18n.backend.populate do
38-
require 'action_view/locale/en-US.rb'
38+
I18n.load_translations File.dirname(__FILE__) + '/action_view/locale/en-US.rb'
3939
end
4040

4141
ActionView::Base.class_eval do
Lines changed: 78 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,87 @@
1-
I18n.backend.store_translations :'en-US', {
2-
:datetime => {
3-
:distance_in_words => {
4-
:half_a_minute => 'half a minute',
5-
:less_than_x_seconds => {
6-
:one => 'less than 1 second',
7-
:many => 'less than {{count}} seconds'
8-
},
9-
:x_seconds => {
10-
:one => '1 second',
11-
:many => '{{count}} seconds'
12-
},
13-
:less_than_x_minutes => {
14-
:one => 'less than a minute',
15-
:many => 'less than {{count}} minutes'
16-
},
17-
:x_minutes => {
18-
:one => '1 minute',
19-
:many => '{{count}} minutes'
20-
},
21-
:about_x_hours => {
22-
:one => 'about 1 hour',
23-
:many => 'about {{count}} hours'
24-
},
25-
:x_days => {
26-
:one => '1 day',
27-
:many => '{{count}} days'
1+
{ :'en-US' => {
2+
:datetime => {
3+
:distance_in_words => {
4+
:half_a_minute => 'half a minute',
5+
:less_than_x_seconds => {
6+
:one => 'less than 1 second',
7+
:many => 'less than {{count}} seconds'
8+
},
9+
:x_seconds => {
10+
:one => '1 second',
11+
:many => '{{count}} seconds'
12+
},
13+
:less_than_x_minutes => {
14+
:one => 'less than a minute',
15+
:many => 'less than {{count}} minutes'
16+
},
17+
:x_minutes => {
18+
:one => '1 minute',
19+
:many => '{{count}} minutes'
20+
},
21+
:about_x_hours => {
22+
:one => 'about 1 hour',
23+
:many => 'about {{count}} hours'
24+
},
25+
:x_days => {
26+
:one => '1 day',
27+
:many => '{{count}} days'
28+
},
29+
:about_x_months => {
30+
:one => 'about 1 month',
31+
:many => 'about {{count}} months'
32+
},
33+
:x_months => {
34+
:one => '1 month',
35+
:many => '{{count}} months'
36+
},
37+
:about_x_years => {
38+
:one => 'about 1 year',
39+
:many => 'about {{count}} years'
40+
},
41+
:over_x_years => {
42+
:one => 'over 1 year',
43+
:many => 'over {{count}} years'
44+
}
45+
}
46+
},
47+
:number => {
48+
:format => {
49+
:precision => 3,
50+
:separator => '.',
51+
:delimiter => ','
2852
},
29-
:about_x_months => {
30-
:one => 'about 1 month',
31-
:many => 'about {{count}} months'
53+
:currency => {
54+
:format => {
55+
:unit => '$',
56+
:precision => 2,
57+
:format => '%u%n'
58+
}
3259
},
33-
:x_months => {
34-
:one => '1 month',
35-
:many => '{{count}} months'
60+
:human => {
61+
:format => {
62+
:precision => 1,
63+
:delimiter => ''
64+
}
3665
},
37-
:about_x_years => {
38-
:one => 'about 1 year',
39-
:many => 'about {{count}} years'
66+
:percentage => {
67+
:format => {
68+
:delimiter => ''
69+
}
4070
},
41-
:over_x_years => {
42-
:one => 'over 1 year',
43-
:many => 'over {{count}} years'
71+
:precision => {
72+
:format => {
73+
:delimiter => ''
74+
}
4475
}
45-
}
46-
},
47-
:number => {
48-
:format => {
49-
:precision => 3,
50-
:separator => '.',
51-
:delimiter => ','
5276
},
53-
:currency => {
54-
:format => {
55-
:unit => '$',
56-
:precision => 2,
57-
:format => '%u%n'
77+
:active_record => {
78+
:error => {
79+
:header_message => {
80+
:one => "1 error prohibited this {{object_name}} from being saved",
81+
:many => "{{count}} errors prohibited this {{object_name}} from being saved"
82+
},
83+
:message => "There were problems with the following fields:"
5884
}
59-
},
60-
:human => {
61-
:format => {
62-
:precision => 1,
63-
:delimiter => ''
64-
}
65-
},
66-
:percentage => {
67-
:format => {
68-
:delimiter => ''
69-
}
70-
},
71-
:precision => {
72-
:format => {
73-
:delimiter => ''
74-
}
75-
}
76-
},
77-
:active_record => {
78-
:error => {
79-
:header_message => {
80-
:one => "1 error prohibited this {{object_name}} from being saved",
81-
:many => "{{count}} errors prohibited this {{object_name}} from being saved"
82-
},
83-
:message => "There were problems with the following fields:"
8485
}
8586
}
86-
}
87+
}

activerecord/lib/active_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@
8282
require 'active_record/schema_dumper'
8383

8484
I18n.backend.populate do
85-
require 'active_record/locale/en-US.rb'
85+
I18n.load_translations File.dirname(__FILE__) + '/active_record/locale/en-US.rb'
8686
end
8787

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
I18n.backend.store_translations :'en-US', {
2-
:active_record => {
3-
:error_messages => {
4-
:inclusion => "is not included in the list",
5-
:exclusion => "is reserved",
6-
:invalid => "is invalid",
7-
:confirmation => "doesn't match confirmation",
8-
:accepted => "must be accepted",
9-
:empty => "can't be empty",
10-
:blank => "can't be blank",
11-
:too_long => "is too long (maximum is {{count}} characters)",
12-
:too_short => "is too short (minimum is {{count}} characters)",
13-
:wrong_length => "is the wrong length (should be {{count}} characters)",
14-
:taken => "has already been taken",
15-
:not_a_number => "is not a number",
16-
:greater_than => "must be greater than {{count}}",
17-
:greater_than_or_equal_to => "must be greater than or equal to {{count}}",
18-
:equal_to => "must be equal to {{count}}",
19-
:less_than => "must be less than {{count}}",
20-
:less_than_or_equal_to => "must be less than or equal to {{count}}",
21-
:odd => "must be odd",
22-
:even => "must be even"
23-
}
1+
{ :'en-US' => {
2+
:active_record => {
3+
:error_messages => {
4+
:inclusion => "is not included in the list",
5+
:exclusion => "is reserved",
6+
:invalid => "is invalid",
7+
:confirmation => "doesn't match confirmation",
8+
:accepted => "must be accepted",
9+
:empty => "can't be empty",
10+
:blank => "can't be blank",
11+
:too_long => "is too long (maximum is {{count}} characters)",
12+
:too_short => "is too short (minimum is {{count}} characters)",
13+
:wrong_length => "is the wrong length (should be {{count}} characters)",
14+
:taken => "has already been taken",
15+
:not_a_number => "is not a number",
16+
:greater_than => "must be greater than {{count}}",
17+
:greater_than_or_equal_to => "must be greater than or equal to {{count}}",
18+
:equal_to => "must be equal to {{count}}",
19+
:less_than => "must be less than {{count}}",
20+
:less_than_or_equal_to => "must be less than or equal to {{count}}",
21+
:odd => "must be odd",
22+
:even => "must be even"
23+
}
24+
}
2425
}
2526
}

activesupport/lib/active_support.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858

5959
require 'active_support/time_with_zone'
6060

61-
I18n.backend.populate do
62-
require 'active_support/locale/en-US.rb'
61+
I18n.populate do
62+
I18n.load_translations File.dirname(__FILE__) + '/active_support/locale/en-US.rb'
6363
end
6464

6565
Inflector = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Inflector', 'ActiveSupport::Inflector')
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
I18n.backend.store_translations :'en-US', {
2-
:support => {
3-
:array => {
4-
:sentence_connector => 'and'
5-
}
6-
},
7-
:date => {
8-
:formats => {
9-
:default => "%Y-%m-%d",
10-
:short => "%b %d",
11-
:long => "%B %d, %Y",
1+
{ :'en-US' => {
2+
:support => {
3+
:array => {
4+
:sentence_connector => 'and'
5+
}
126
},
13-
:day_names => Date::DAYNAMES,
14-
:abbr_day_names => Date::ABBR_DAYNAMES,
15-
:month_names => Date::MONTHNAMES,
16-
:abbr_month_names => Date::ABBR_MONTHNAMES,
17-
:order => [:year, :month, :day]
18-
},
19-
:time => {
20-
:formats => {
21-
:default => "%a, %d %b %Y %H:%M:%S %z",
22-
:short => "%d %b %H:%M",
23-
:long => "%B %d, %Y %H:%M",
7+
:date => {
8+
:formats => {
9+
:default => "%Y-%m-%d",
10+
:short => "%b %d",
11+
:long => "%B %d, %Y",
12+
},
13+
:day_names => Date::DAYNAMES,
14+
:abbr_day_names => Date::ABBR_DAYNAMES,
15+
:month_names => Date::MONTHNAMES,
16+
:abbr_month_names => Date::ABBR_MONTHNAMES,
17+
:order => [:year, :month, :day]
2418
},
25-
:am => 'am',
26-
:pm => 'pm'
19+
:time => {
20+
:formats => {
21+
:default => "%a, %d %b %Y %H:%M:%S %z",
22+
:short => "%d %b %H:%M",
23+
:long => "%B %d, %Y %H:%M",
24+
},
25+
:am => 'am',
26+
:pm => 'pm'
27+
}
2728
}
2829
}

0 commit comments

Comments
 (0)