Search code examples
ruby-on-railsrecaptchai18n-gem

What is the right translation tag to translate the Recaptcha error message


Currently I am developing an app. My user registration uses the recaptcha plugin. When the Captcha is wrong, the app gets the error:

  • incorrect-captcha-sol

How can I translate this message with I18n.t?


Solution

  • Hm

    I found a solution to translate this message n the Recaptcha documentation page.

    The verify_recaptcha method provide the :message option but this does not worked for me.

    respond_to do |format|
      if verify_recaptcha(:model => @post, :message => 'Oh! It's error with reCAPTCHA!') && @post.save
      # ...
       else
      # ...
      end
    end
    

    I overwrite the flash message. (thx to slobodan)

    respond_to do |format|
     if verify_recaptcha
      # ...
     else
       flash[:recaptcha_error] = I18n.t("defaults.recaptcha")
       # ...
     end
    end