Sha256: c148d40162380674d1760fe749aeb47ebe604e6a364590c82e8db3f1fd78f0e3

Contents?: true

Size: 729 Bytes

Versions: 3

Compression:

Stored size: 729 Bytes

Contents

module Locomotive
  module Steam
    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

3 entries across 3 versions & 1 rubygems

Version Path
locomotivecms_steam-0.1.2.pre.beta lib/locomotive/steam/liquid/filters/translate.rb
locomotivecms_steam-0.1.1 lib/locomotive/steam/liquid/filters/translate.rb
locomotivecms_steam-0.1.0 lib/locomotive/steam/liquid/filters/translate.rb