File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ def fallbacks
20
20
21
21
# Sets the current fallbacks implementation. Use this to set a different fallbacks implementation.
22
22
def fallbacks = ( fallbacks )
23
- @@fallbacks = fallbacks . is_a? ( I18n :: Locale :: Fallbacks ) ? fallbacks : I18n ::Locale ::Fallbacks . new ( fallbacks )
23
+ @@fallbacks = fallbacks . is_a? ( Array ) ? I18n ::Locale ::Fallbacks . new ( fallbacks ) : fallbacks
24
24
end
25
25
end
26
26
Original file line number Diff line number Diff line change @@ -128,6 +128,35 @@ def setup
128
128
end
129
129
end
130
130
131
+ # See Issue #536
132
+ class I18nBackendFallbacksWithCustomClass < I18n ::TestCase
133
+ class BackendWithFallbacks < I18n ::Backend ::Simple
134
+ include I18n ::Backend ::Fallbacks
135
+ end
136
+
137
+ # Quacks like a fallback class
138
+ class MyDefaultFallback
139
+ def []( key )
140
+ [ :my_language ]
141
+ end
142
+ end
143
+
144
+ def setup
145
+ super
146
+ I18n . backend = BackendWithFallbacks . new
147
+ I18n . enforce_available_locales = false
148
+ I18n . fallbacks = MyDefaultFallback . new
149
+ store_translations ( :my_language , foo : 'customer foo' )
150
+ store_translations ( :en , foo : 'english foo' )
151
+ end
152
+
153
+ test "can use a default fallback object that doesn't inherit from I18n::Locale::Fallbacks" do
154
+ assert_equal 'customer foo' , I18n . t ( :foo , locale : :en )
155
+ assert_equal 'customer foo' , I18n . t ( :foo , locale : :nothing )
156
+ end
157
+ end
158
+
159
+
131
160
class I18nBackendFallbacksLocalizeTest < I18n ::TestCase
132
161
class Backend < I18n ::Backend ::Simple
133
162
include I18n ::Backend ::Fallbacks
You can’t perform that action at this time.
0 commit comments