Module: Cloudflare::Turnstile::Rails::ErrorMessage

Defined in:
lib/cloudflare/turnstile/rails/constants/error_message.rb

Constant Summary collapse

SCOPE =

I18n namespace for all error message translations

'cloudflare_turnstile.errors'.freeze
FALLBACK =

Fallback message used when no translation exists for an error code. This can happen if Cloudflare introduces a new error code that we haven’t added to our locale files yet. Rails I18n fallbacks are respected if configured (config.i18n.fallbacks = true).

"We could not verify that you're human. Please try again.".freeze

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object

Backwards compatibility: ErrorMessage::DEFAULT still works (deprecated)



25
26
27
28
29
30
31
32
# File 'lib/cloudflare/turnstile/rails/constants/error_message.rb', line 25

def self.const_missing(name)
  if name == :DEFAULT
    warn '[DEPRECATION] ErrorMessage::DEFAULT is deprecated. Use ErrorMessage.default instead.'
    return default
  end

  super
end

.defaultObject



20
21
22
# File 'lib/cloudflare/turnstile/rails/constants/error_message.rb', line 20

def self.default
  translate(:default)
end

.for(code) ⇒ Object



16
17
18
# File 'lib/cloudflare/turnstile/rails/constants/error_message.rb', line 16

def self.for(code)
  "#{translate(key_for(code))} (#{code})"
end