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.27 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.26 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.45 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.25 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.23 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.44 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.22 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.43 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.21 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.42 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.20 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.41 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.19 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.40 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.18 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.39 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.17 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.38 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.5.16 lib/workarea/ext/freedom_patches/i18n_js.rb
workarea-core-3.4.37 lib/workarea/ext/freedom_patches/i18n_js.rb