Question

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?

Was it helpful?

Solution 2

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

OTHER TIPS

Recaptcha v0.3.4 does not translate the error: https://github.com/ambethia/recaptcha/blob/043cec2b64646ec270f2b30cfc55da661145e3ae/lib/recaptcha/verify.rb

This is fixed in the master branch.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top