Sha256: 6e3854ce360d14c891eafc37fa7d3c581cd7d7873c829c8f388a76d949e0f0f0

Contents?: true

Size: 484 Bytes

Versions: 6

Compression:

Stored size: 484 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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-validation-0.8.0 lib/dry/validation/messages/i18n.rb
dry-validation-0.7.4 lib/dry/validation/messages/i18n.rb
dry-validation-0.7.3 lib/dry/validation/messages/i18n.rb
dry-validation-0.7.2 lib/dry/validation/messages/i18n.rb
dry-validation-0.7.1 lib/dry/validation/messages/i18n.rb
dry-validation-0.7.0 lib/dry/validation/messages/i18n.rb