Sha256: 128b862009a7e656a6bc5ef2a2e48c4f88fd1ffc653d1095d3ee5ed30d0086cc

Contents?: true

Size: 1.16 KB

Versions: 31

Compression:

Stored size: 1.16 KB

Contents

module I18n
  module JS
    class FallbackLocales
      # 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: https://github.com/fnando/i18n-js/blob/master/lib/i18n/js/fallback_locales.rb#L49-L58
      #
      def using_i18n_fallbacks_module?
        I18n.respond_to?(:fallbacks) &&
          I18n::JS.backend.class.included_modules.include?(I18n::Backend::Fallbacks)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
workarea-core-3.5.15 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.36 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.14 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.35 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.13 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.34 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.12 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.33 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.11 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.10 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.32 lib/workarea/ext/freedom_patches/i18n_js.rb