File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
lib/active_support/inflector Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ module Inflector
30
30
# before any of the rules that may already have been loaded.
31
31
class Inflections
32
32
@__instance__ = Concurrent ::Map . new
33
+ @__en_instance__ = nil
33
34
34
35
class Uncountables # :nodoc:
35
36
include Enumerable
@@ -74,10 +75,14 @@ def uncountable?(str)
74
75
end
75
76
76
77
def self . instance ( locale = :en )
78
+ return @__en_instance__ ||= new if locale == :en
79
+
77
80
@__instance__ [ locale ] ||= new
78
81
end
79
82
80
83
def self . instance_or_fallback ( locale )
84
+ return @__en_instance__ ||= new if locale == :en
85
+
81
86
I18n . fallbacks [ locale ] . each do |k |
82
87
return @__instance__ [ k ] if @__instance__ . key? ( k )
83
88
end
Original file line number Diff line number Diff line change @@ -16,12 +16,16 @@ def setup
16
16
# This helper is implemented by setting @__instance__ because in some tests
17
17
# there are module functions that access ActiveSupport::Inflector.inflections,
18
18
# so we need to replace the singleton itself.
19
- @original_inflections = ActiveSupport ::Inflector ::Inflections . instance_variable_get ( :@__instance__ ) [ :en ]
20
- ActiveSupport ::Inflector ::Inflections . instance_variable_set ( :@__instance__ , en : @original_inflections . dup )
19
+ @original_inflections = ActiveSupport ::Inflector ::Inflections . instance_variable_get ( :@__instance__ )
20
+ @original_inflection_en = ActiveSupport ::Inflector ::Inflections . instance_variable_get ( :@__en_instance__ )
21
+
22
+ ActiveSupport ::Inflector ::Inflections . instance_variable_set ( :@__instance__ , { } )
23
+ ActiveSupport ::Inflector ::Inflections . instance_variable_set ( :@__en_instance__ , @original_inflection_en . dup )
21
24
end
22
25
23
26
def teardown
24
- ActiveSupport ::Inflector ::Inflections . instance_variable_set ( :@__instance__ , en : @original_inflections )
27
+ ActiveSupport ::Inflector ::Inflections . instance_variable_set ( :@__instance__ , @original_inflections )
28
+ ActiveSupport ::Inflector ::Inflections . instance_variable_set ( :@__en_instance__ , @original_inflection_en )
25
29
end
26
30
27
31
def test_pluralize_plurals
You can’t perform that action at this time.
0 commit comments