Sha256: edb97ac991d68d1fe973e23b1e2c6216031e69ce8e57d3303d1837b21f6a9820

Contents?: true

Size: 729 Bytes

Versions: 19

Compression:

Stored size: 729 Bytes

Contents

module Locomotive
  module Wagon
    module Liquid
      module Filters
        module Translate

          def translate(key, locale = nil, scope = nil)
            locale ||= I18n.locale.to_s
            if scope.blank?
              translation = @context.registers[:mounting_point].translations[key.to_s]

              if translation
                translation.get(locale) || translation.get(Locomotive::Mounter.locale.to_s)
              else
                "[unknown translation key: #{key}]"
              end
            else
              I18n.t(key, scope: scope.split('.'), locale: locale)
            end
          end
        end

        ::Liquid::Template.register_filter(Translate)

      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
locomotivecms_wagon-1.5.8 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.5.7 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.5.6 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.5.5 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.5.4 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.5.3 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.5.2 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.5.1 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.5.0 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.5.0.rc1 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.4.0 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.3.3 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.3.2 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.3.1 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.3.0 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.2.2 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.2.1 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.2.0 lib/locomotive/wagon/liquid/filters/translate.rb
locomotivecms_wagon-1.1.0 lib/locomotive/wagon/liquid/filters/translate.rb