Sha256: ca1732380d8ab78ea6fe2bd868da99b5b756756ad471428efb5248beb1e26017

Contents?: true

Size: 563 Bytes

Versions: 5

Compression:

Stored size: 563 Bytes

Contents

require 'i18n'
require 'dry/validation/messages/abstract'

module Dry
  module Validation
    class Messages::I18n < Messages::Abstract
      attr_reader :t

      ::I18n.load_path.concat(config.paths)

      def initialize
        super
        @t = I18n.method(:t)
      end

      def get(key, options = {})
        t.(key, options) if key
      end

      def key?(key, options)
        ::I18n.exists?(key, options.fetch(:locale, I18n.default_locale))
      end

      def merge(path)
        ::I18n.load_path << path
        self
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-validation-0.9.4 lib/dry/validation/messages/i18n.rb
dry-validation-0.9.3 lib/dry/validation/messages/i18n.rb
dry-validation-0.9.2 lib/dry/validation/messages/i18n.rb
dry-validation-0.9.1 lib/dry/validation/messages/i18n.rb
dry-validation-0.9.0 lib/dry/validation/messages/i18n.rb