Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixes localization for nonscript version and error expression #66

Merged
merged 2 commits into from

2 participants

@akalyaev

Localization for nonscript version

See #21 issue

error expression

For some reasons, this code:
error = options[:error] ||= (defined? flash ? flash[:recaptcha_error] : "")
returns "expression" for me instead of "incorrect-captcha-sol"

I've fixed this using brackets:
error = options[:error] ||= ((defined? flash) ? flash[:recaptcha_error] : "")

ruby - 1.9.2
rails - 3.2.1

Sorry for not providing tests. Hope it will be usefull.

@ambethia ambethia merged commit 0c4d3f7 into ambethia:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2012
  1. @akalyaev
  2. @akalyaev

    fixed error expression

    akalyaev authored
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/recaptcha/client_helper.rb
View
8 lib/recaptcha/client_helper.rb
@@ -6,8 +6,9 @@ def recaptcha_tags(options = {})
# Default options
key = options[:public_key] ||= Recaptcha.configuration.public_key
raise RecaptchaError, "No public key specified." unless key
- error = options[:error] ||= (defined? flash ? flash[:recaptcha_error] : "")
+ error = options[:error] ||= ((defined? flash) ? flash[:recaptcha_error] : "")
uri = Recaptcha.configuration.api_server_url(options[:ssl])
+ lang = options[:display] && options[:display][:lang] ? options[:display][:lang].to_sym : ""
html = ""
if options[:display]
html << %{<script type="text/javascript">\n}
@@ -31,7 +32,8 @@ def recaptcha_tags(options = {})
EOS
else
html << %{<script type="text/javascript" src="#{uri}/challenge?k=#{key}}
- html << %{#{error ? "&amp;error=#{CGI::escape(error)}" : ""}"></script>\n}
+ html << %{#{error ? "&amp;error=#{CGI::escape(error)}" : ""}}
+ html << %{#{lang ? "&amp;lang=#{lang}" : ""}"></script>\n}
unless options[:noscript] == false
html << %{<noscript>\n }
html << %{<iframe src="#{uri}/noscript?k=#{key}" }
@@ -48,4 +50,4 @@ def recaptcha_tags(options = {})
return (html.respond_to?(:html_safe) && html.html_safe) || html
end # recaptcha_tags
end # ClientHelper
-end # Recaptcha
+end # Recaptcha
Something went wrong with that request. Please try again.