Sha256: 2c07641c346669eccc865de48b8d7a0fb1157528d3837ea589a038bab4bde046

Contents?: true

Size: 455 Bytes

Versions: 1

Compression:

Stored size: 455 Bytes

Contents

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

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

      ::I18n.load_path << config.path

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-validation-0.3.0 lib/dry/validation/messages/i18n.rb