Class: I18n::JS::FallbackLocales
- Inherits:
-
Object
- Object
- I18n::JS::FallbackLocales
- Defined in:
- lib/workarea/ext/freedom_patches/i18n_js.rb
Instance Method Summary collapse
-
#using_i18n_fallbacks_module? ⇒ Boolean
i18n-js uses just the second part of this check out-of-the-box.
Instance Method Details
#using_i18n_fallbacks_module? ⇒ Boolean
i18n-js uses just the second part of this check out-of-the-box. This causes the I18n fallbacks to get autoloaded without the developer knowing.
This surfaces in tests. System or integration tests will do this check for compiling assets, then I18n fallbacks get autoloaded. So this shows as some tests not having fallbacks if they run before one of those tests or magically having fallbacks if they run after one of those types of tests.
Adding the ‘respond_to?` check doesn’t cause autoload, but will return ‘true` if fallbacks are enabled. Retain the original check because we want the current I18n::JS backend to be checked, once fallbacks are `require`d `I18n.respond_to?(:fallbacks)` will always return `true`.
See also: github.com/fnando/i18n-js/blob/master/lib/i18n/js/fallback_locales.rb#L49-L58
21 22 23 24 |
# File 'lib/workarea/ext/freedom_patches/i18n_js.rb', line 21 def using_i18n_fallbacks_module? I18n.respond_to?(:fallbacks) && I18n::JS.backend.class.included_modules.include?(I18n::Backend::Fallbacks) end |